Class: OCms::GalleriesController
- Inherits:
-
ApplicationController
- Object
- ActionController::Base
- ApplicationController
- OCms::GalleriesController
- Defined in:
- app/controllers/o_cms/galleries_controller.rb
Instance Method Summary collapse
- #create ⇒ Object
- #destroy ⇒ Object
- #edit ⇒ Object
- #index ⇒ Object
- #new ⇒ Object
- #show ⇒ Object
- #update ⇒ Object
Instance Method Details
#create ⇒ Object
19 20 21 22 23 24 25 26 27 28 29 |
# File 'app/controllers/o_cms/galleries_controller.rb', line 19 def create @gallery = Gallery.new(gallery_params) if @gallery.save flash[:notice] = "Gallery was saved successfully." redirect_to edit_gallery_path(@gallery) else flash.now[:alert] = "Error creating gallery. Please try again." render :new end end |
#destroy ⇒ Object
49 50 51 52 53 54 55 56 57 58 59 |
# File 'app/controllers/o_cms/galleries_controller.rb', line 49 def destroy @gallery = Gallery.find(params[:id]) if @gallery.destroy flash[:notice] = "\"#{@gallery.name}\" was deleted successfully." redirect_to action: :index else flash.now[:alert] = "There was an error deleting the gallery." render :show end end |
#edit ⇒ Object
31 32 33 34 |
# File 'app/controllers/o_cms/galleries_controller.rb', line 31 def edit @gallery = Gallery.find(params[:id]) @images = Image.all end |
#index ⇒ Object
6 7 8 |
# File 'app/controllers/o_cms/galleries_controller.rb', line 6 def index @galleries = Gallery.all end |
#new ⇒ Object
14 15 16 17 |
# File 'app/controllers/o_cms/galleries_controller.rb', line 14 def new @gallery = Gallery.new @images = Image.all end |
#show ⇒ Object
10 11 12 |
# File 'app/controllers/o_cms/galleries_controller.rb', line 10 def show @gallery = Gallery.find(params[:id]) end |
#update ⇒ Object
36 37 38 39 40 41 42 43 44 45 46 47 |
# File 'app/controllers/o_cms/galleries_controller.rb', line 36 def update @gallery = Gallery.find(params[:id]) @gallery.assign_attributes(gallery_params) if @gallery.save flash[:notice] = "Gallery was updated successfully." redirect_to edit_gallery_path(@gallery) else flash.now[:alert] = "Error saving gallery. Please try again." render :edit end end |