Class: Grandstand::ImagesController
- Inherits:
-
MainController
- Object
- ApplicationController
- MainController
- Grandstand::ImagesController
- Defined in:
- app/controllers/grandstand/images_controller.rb
Instance Method Summary collapse
-
#create ⇒ Object
session :cookies_only => false, :only => :create.
- #delete ⇒ Object
- #destroy ⇒ Object
- #edit ⇒ Object
- #index ⇒ Object
- #new ⇒ Object
- #reorder ⇒ Object
- #update ⇒ Object
- #upload ⇒ Object
Methods inherited from MainController
Instance Method Details
#create ⇒ Object
session :cookies_only => false, :only => :create
7 8 9 10 11 12 13 14 15 16 17 18 19 |
# File 'app/controllers/grandstand/images_controller.rb', line 7 def create @image = @gallery.images.new(params[:image]) if @image.save if params.has_key?('Filename') || request.xhr? render(:json => {:status => :ok}) else flash[:success] = 'Your image was successfully uploaded' redirect_to(grandstand_gallery_path(@gallery)) end else render :new end end |
#delete ⇒ Object
21 22 |
# File 'app/controllers/grandstand/images_controller.rb', line 21 def delete end |
#destroy ⇒ Object
24 25 26 27 28 |
# File 'app/controllers/grandstand/images_controller.rb', line 24 def destroy @image.destroy flash[:delete] = 'Your image has been deleted' redirect_to grandstand_gallery_path(@gallery) end |
#edit ⇒ Object
30 31 32 |
# File 'app/controllers/grandstand/images_controller.rb', line 30 def edit @image = @gallery.images.find(params[:id]) end |
#index ⇒ Object
34 35 36 |
# File 'app/controllers/grandstand/images_controller.rb', line 34 def index redirect_to grandstand_gallery_path(@gallery) end |
#new ⇒ Object
38 39 40 |
# File 'app/controllers/grandstand/images_controller.rb', line 38 def new @image = Grandstand::Image.new end |
#reorder ⇒ Object
42 43 44 45 46 47 |
# File 'app/controllers/grandstand/images_controller.rb', line 42 def reorder params[:images].each_with_index do |image_id, index| @gallery.images.update(image_id, :position => index + 1) end if params[:images] render :json => {:status => :ok} end |
#update ⇒ Object
49 50 51 52 53 54 55 56 |
# File 'app/controllers/grandstand/images_controller.rb', line 49 def update if @image.update_attributes(params[:image]) flash[:success] = 'Your image was successfully saved' request.xhr? ? render(:json => {:status => :ok}) : redirect_to(grandstand_gallery_path(@gallery)) else render :new end end |
#upload ⇒ Object
59 60 |
# File 'app/controllers/grandstand/images_controller.rb', line 59 def upload end |