Class: Redditor::Admin::ImageBlocksController

Inherits:
BaseController
  • Object
show all
Defined in:
app/controllers/redditor/admin/image_blocks_controller.rb

Instance Method Summary collapse

Instance Method Details

#createObject

[View source]

15
16
17
18
19
# File 'app/controllers/redditor/admin/image_blocks_controller.rb', line 15

def create
  @content_block = @page.images.build(content_block_params)
  @content_block.update_attributes(src: params[:file])
  render "redditor/admin/wrapper"
end

#destroyObject

[View source]

21
22
23
24
25
26
27
28
# File 'app/controllers/redditor/admin/image_blocks_controller.rb', line 21

def destroy
  @content_block = @page.images.find(params[:id])
  if @content_block.destroy
    render js: "$('#image_#{@content_block.id}').closest('dd').remove();"
  else
    render js: "alert('Контент-блок не удален');"
  end
end

#newObject

[View source]

4
5
6
7
# File 'app/controllers/redditor/admin/image_blocks_controller.rb', line 4

def new
  @content_block = @page.images.build(content_block_params)
  render "redditor/admin/new"
end

#updateObject

[View source]

9
10
11
12
13
# File 'app/controllers/redditor/admin/image_blocks_controller.rb', line 9

def update
  @content_block = @page.images.find(params[:id])
  @content_block.update_attributes(content_block_params)
  render "redditor/admin/wrapper"
end

#update_postObject

[View source]

30
31
32
33
34
# File 'app/controllers/redditor/admin/image_blocks_controller.rb', line 30

def update_post
  @content_block = @page.images.find(params[:id])
  @content_block.update_attributes(src: params[:file])
  render "redditor/admin/wrapper"
end