adding new section
This commit is contained in:
@ -1,11 +1,12 @@
|
||||
module Merged
|
||||
class SectionsController < MergedController
|
||||
before_action :set_section , except: :index
|
||||
before_action :set_section , except: [:index ,:new]
|
||||
#, only: %i[ show edit update destroy set_image select_image]
|
||||
|
||||
def index
|
||||
@page = Page.find(params[:page_id])
|
||||
end
|
||||
|
||||
def select_image
|
||||
@images = Image.all
|
||||
end
|
||||
@ -16,6 +17,12 @@ module Merged
|
||||
@cards = Style.cards
|
||||
end
|
||||
|
||||
def new
|
||||
page = Page.find(params[:page_id])
|
||||
new_section = page.new_section
|
||||
redirect_to section_select_template_url(new_section.id)
|
||||
end
|
||||
|
||||
def set_image
|
||||
@section.content["image"] = params[:image]
|
||||
@section.save
|
||||
@ -49,9 +56,9 @@ module Merged
|
||||
end
|
||||
|
||||
def update
|
||||
@section.content.each do |key , value|
|
||||
next if key == "id"
|
||||
if(!params[key].nil?)
|
||||
@section.allowed_fields.each do |key|
|
||||
puts "Update #{key}"
|
||||
if( params.has_key?(key) )
|
||||
@section.update(key, params[key])
|
||||
puts "updating:#{key}=#{params[key]}"
|
||||
end
|
||||
|
Reference in New Issue
Block a user