Class: Adminpanel::GalleriesController
- Inherits:
-
ApplicationController
- Object
- ApplicationController
- Adminpanel::GalleriesController
- Defined in:
- app/controllers/adminpanel/galleries_controller.rb
Instance Method Summary collapse
-
#create ⇒ Object
def edit @gallery = Gallery.find(params) end.
- #destroy ⇒ Object
- #index ⇒ Object
- #move_better ⇒ Object
- #move_worst ⇒ Object
- #show ⇒ Object
- #update ⇒ Object
Instance Method Details
#create ⇒ Object
def edit @gallery = Gallery.find(params) end
17 18 19 20 21 22 23 24 25 |
# File 'app/controllers/adminpanel/galleries_controller.rb', line 17 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
63 64 65 66 67 68 |
# File 'app/controllers/adminpanel/galleries_controller.rb', line 63 def destroy @gallery = Gallery.find(params[:id]) @gallery.destroy redirect_to galleries_path, :notice => t("gallery.deleted") end |
#index ⇒ Object
5 6 7 |
# File 'app/controllers/adminpanel/galleries_controller.rb', line 5 def index @galleries = Gallery.find(:all) end |
#move_better ⇒ Object
27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 |
# File 'app/controllers/adminpanel/galleries_controller.rb', line 27 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
45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 |
# File 'app/controllers/adminpanel/galleries_controller.rb', line 45 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 |
#show ⇒ Object
9 10 11 |
# File 'app/controllers/adminpanel/galleries_controller.rb', line 9 def show @gallery = Gallery.find(params[:id]) end |
#update ⇒ Object
70 71 72 73 74 75 76 77 |
# File 'app/controllers/adminpanel/galleries_controller.rb', line 70 def update @gallery = Gallery.find(params[:id]) if @gallery.update_attributes(params[:gallery]) redirect_to gallery_path(@gallery) else render 'edit' end end |