Class: Kuhsaft::Cms::BricksController
Instance Method Summary
collapse
#default_url_options, #set_content_locale
Instance Method Details
#create ⇒ Object
6
7
8
9
10
11
12
13
14
15
16
17
18
|
# File 'app/controllers/kuhsaft/cms/bricks_controller.rb', line 6
def create
@brick = params[:brick][:type].constantize.create(brick_params)
@brick.image_size ||= ImageSize.all.first.name.to_s
if @brick.valid?
respond_with @brick do |format|
format.js
format.html { redirect_to edit_cms_page_path(@brick.parents.first) }
end
else
render 'new'
end
end
|
#destroy ⇒ Object
39
40
41
42
43
|
# File 'app/controllers/kuhsaft/cms/bricks_controller.rb', line 39
def destroy
@brick = Kuhsaft::Brick.find(params[:id])
@parent_brick = @brick.brick_list
@brick.destroy
end
|
#new ⇒ Object
20
21
22
|
# File 'app/controllers/kuhsaft/cms/bricks_controller.rb', line 20
def new
@brick = Kuhsaft::Brick.new(brick_params)
end
|
#sort ⇒ Object
45
46
47
48
49
50
51
52
|
# File 'app/controllers/kuhsaft/cms/bricks_controller.rb', line 45
def sort
if params[:bricks].present?
params[:bricks][:ids].split(',').each_with_index do |id, idx|
Kuhsaft::Brick.find(id).update_attribute(:position, idx.to_i + 1)
end
end
render nothing: true
end
|
#update ⇒ Object
24
25
26
27
28
29
30
31
32
33
34
35
36
37
|
# File 'app/controllers/kuhsaft/cms/bricks_controller.rb', line 24
def update
@brick = Kuhsaft::Brick.find(params[:id])
@brick.update_attributes(brick_params)
respond_with @brick do |format|
format.js
format.html { redirect_to edit_cms_page_path(@brick.parents.first) }
end
end
|