Class: Adminpanel::GalleriesController
- Inherits:
-
ApplicationController
- Object
- ApplicationController
- Adminpanel::GalleriesController
- Defined in:
- app/controllers/adminpanel/galleries_controller.rb
Instance Method Summary collapse
- #create ⇒ Object
- #destroy ⇒ Object
- #edit ⇒ Object
- #index ⇒ Object
- #move_better ⇒ Object
- #move_worst ⇒ Object
- #new ⇒ Object
- #show ⇒ Object
- #update ⇒ Object
Instance Method Details
#create ⇒ Object
15 16 17 18 19 20 21 22 23 |
# File 'app/controllers/adminpanel/galleries_controller.rb', line 15 def create @gallery = Gallery.new(params[:gallery]) if @gallery.save redirect_to gallery_path(@gallery), :notice => t("gallery.success") else render 'new' end end |
#destroy ⇒ Object
61 62 63 64 65 66 |
# File 'app/controllers/adminpanel/galleries_controller.rb', line 61 def destroy @gallery = Gallery.find(params[:id]) @gallery.destroy redirect_to galleries_path, :notice => t("gallery.deleted") end |
#edit ⇒ Object
11 12 13 |
# File 'app/controllers/adminpanel/galleries_controller.rb', line 11 def edit @gallery = Gallery.find(params[:id]) end |
#index ⇒ Object
3 4 5 |
# File 'app/controllers/adminpanel/galleries_controller.rb', line 3 def index @galleries = Gallery.find(:all) end |
#move_better ⇒ Object
25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 |
# File 'app/controllers/adminpanel/galleries_controller.rb', line 25 def move_better @gallery = Gallery.find(params[:id]) if @gallery.move_to_better_position flash[:success] = t("gallery.moved") else flash[:warning] = t("gallery.not-moved") end respond_to do |format| format.html do redirect_to galleries_path end format.js do @galleries = Gallery.all render :locals => { :galleries => @galleries } end end end |
#move_worst ⇒ Object
43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 |
# File 'app/controllers/adminpanel/galleries_controller.rb', line 43 def move_worst @gallery = Gallery.find(params[:id]) if @gallery.move_to_worst_position flash[:success] = t("gallery.moved") else flash[:warning] = t("gallery.not-moved") end respond_to do |format| format.html do redirect_to galleries_path end format.js do @galleries = Gallery.all render :locals => { :galleries => @galleries } end end end |
#new ⇒ Object
77 78 79 |
# File 'app/controllers/adminpanel/galleries_controller.rb', line 77 def new @gallery = Gallery.new end |
#show ⇒ Object
7 8 9 |
# File 'app/controllers/adminpanel/galleries_controller.rb', line 7 def show @gallery = Gallery.find(params[:id]) end |
#update ⇒ Object
68 69 70 71 72 73 74 75 |
# File 'app/controllers/adminpanel/galleries_controller.rb', line 68 def update @gallery = Gallery.find(params[:id]) if @gallery.update_attributes(params[:gallery]) redirect_to gallery_path(@gallery) else render 'edit' end end |