gateway/app/controllers/cms/sections_controller.rb

30 lines
687 B
Ruby
Raw Normal View History

module Cms
class SectionsController < CmsController
2022-11-28 00:39:24 +02:00
before_action :set_page, only: %i[ show edit update destroy set_image select_image]
def select_image
@images = Image.all
end
2022-11-26 19:07:20 +02:00
2022-11-27 17:23:38 +02:00
def update
@section.content.each do |key , value|
next if key == "id"
if(!params[key].nil?)
@section.update(key, params[key])
puts "updating:#{key}=#{params[key]}"
end
end
@page.save
redirect_to :cms_page_section
end
2022-11-26 19:07:20 +02:00
private
def set_page
@page = Page.find(params[:page_id])
2022-11-28 00:39:24 +02:00
section_id = params[:id] || params[:section_id]
@section = @page.find_section( section_id )
2022-11-26 19:07:20 +02:00
end
end
end