Class: EtabliocmsGalleries::Admin::GalleriesController
- Inherits:
-
EtabliocmsCore::Admin::BaseController
- Object
- EtabliocmsCore::Admin::BaseController
- EtabliocmsGalleries::Admin::GalleriesController
- Defined in:
- app/controllers/etabliocms_galleries/admin/galleries_controller.rb
Instance Method Summary collapse
- #create ⇒ Object
- #destroy ⇒ Object
- #edit ⇒ Object
- #index ⇒ Object
- #new ⇒ Object
- #sort ⇒ Object
- #sort_pictures ⇒ Object
- #update ⇒ Object
Instance Method Details
#create ⇒ Object
13 14 15 16 17 18 19 20 21 |
# File 'app/controllers/etabliocms_galleries/admin/galleries_controller.rb', line 13 def create @gallery = Gallery.new(params[:etabliocms_galleries_gallery]) if @gallery.save flash[:notice] = t('gallery.created') redirect_to params[:save_and_continue].present? ? edit_admin_gallery_path(@gallery.id) : {:action => 'index'} else render :action => 'new' end end |
#destroy ⇒ Object
37 38 39 40 41 |
# File 'app/controllers/etabliocms_galleries/admin/galleries_controller.rb', line 37 def destroy Gallery.find(params[:id]).destroy flash[:notice] = t('gallery.destroyed') redirect_to :action => 'index' end |
#edit ⇒ Object
23 24 25 |
# File 'app/controllers/etabliocms_galleries/admin/galleries_controller.rb', line 23 def edit @gallery = Gallery.find(params[:id]) end |
#index ⇒ Object
5 6 7 |
# File 'app/controllers/etabliocms_galleries/admin/galleries_controller.rb', line 5 def index @galleries = Gallery.order(params[:order] || "created_at DESC") end |
#new ⇒ Object
9 10 11 |
# File 'app/controllers/etabliocms_galleries/admin/galleries_controller.rb', line 9 def new @gallery = Gallery.new end |
#sort ⇒ Object
43 44 45 46 47 48 49 |
# File 'app/controllers/etabliocms_galleries/admin/galleries_controller.rb', line 43 def sort Gallery.all.each do |gallery| gallery.position = params['etabliocms_galleries_gallery'].index(gallery.id.to_s) + 1 gallery.save end render :nothing => true end |
#sort_pictures ⇒ Object
51 52 53 54 55 56 57 58 |
# File 'app/controllers/etabliocms_galleries/admin/galleries_controller.rb', line 51 def sort_pictures @gallery = Gallery.find(params[:id]) @gallery.pictures.all.each do |picture| picture.position = params['etabliocms_galleries_picture'].index(picture.id.to_s) + 1 picture.save end render :nothing => true end |
#update ⇒ Object
27 28 29 30 31 32 33 34 35 |
# File 'app/controllers/etabliocms_galleries/admin/galleries_controller.rb', line 27 def update @gallery = Gallery.find(params[:id]) if @gallery.update_attributes(params[:etabliocms_galleries_gallery]) flash[:notice] = t('gallery.updated') redirect_to params[:save_and_continue].present? ? edit_admin_gallery_path(@gallery.id) : {:action => 'index'} else render :action => 'edit' end end |