Class: Redditor::Admin::SliderBlocksController
- Inherits:
-
BaseController
- Object
- BaseController
- Redditor::Admin::SliderBlocksController
- Defined in:
- app/controllers/redditor/admin/slider_blocks_controller.rb
Instance Method Summary collapse
Instance Method Details
#change_view ⇒ Object
10 11 12 13 14 15 |
# File 'app/controllers/redditor/admin/slider_blocks_controller.rb', line 10 def change_view @content_block = @page..find(params[:id]) # оставляем только :kind и :object_id параметры, чтобы при возвращении к старому виду описания к фотографиям не сохранялись @content_block.update_attributes(params.require(:content_block).permit(:kind, :object_id)) render "redditor/admin/wrapper" end |
#create ⇒ Object
23 24 25 26 27 28 |
# File 'app/controllers/redditor/admin/slider_blocks_controller.rb', line 23 def create temp_last_postion = @page.try(:content_blocks).try(:last).try(:position).to_i + 1 @content_block = @page..build(content_block_params) @content_block.update_attributes(position: temp_last_postion) render "redditor/admin/new" end |
#destroy ⇒ Object
30 31 32 33 34 35 36 37 |
# File 'app/controllers/redditor/admin/slider_blocks_controller.rb', line 30 def destroy @content_block = @page..find(params[:id]) if @content_block.destroy render :js => "$('#slider_block_#{@content_block.id}').closest('dd').remove();" else render :js => "alert('Контент-блок не удален');" end end |
#new ⇒ Object
5 6 7 8 |
# File 'app/controllers/redditor/admin/slider_blocks_controller.rb', line 5 def new @content_block = @page..build(content_block_params) render "redditor/admin/new" end |
#update ⇒ Object
17 18 19 20 21 |
# File 'app/controllers/redditor/admin/slider_blocks_controller.rb', line 17 def update @content_block = @page..find(params[:id]) @content_block.update_attributes(content_block_params) render "redditor/admin/wrapper" end |