flattened routes, lots of paths and arg changes
This commit is contained in:
@ -1,9 +1,9 @@
|
||||
module Merged
|
||||
class CardsController < MergedController
|
||||
before_action :set_page
|
||||
before_action :set_card , except: :index
|
||||
|
||||
def index
|
||||
|
||||
@section = Section.find(params[:section_id])
|
||||
end
|
||||
|
||||
private
|
||||
|
@ -4,7 +4,7 @@ module Merged
|
||||
|
||||
# GET /merged/pages
|
||||
def index
|
||||
@pages = Merged::Page.all
|
||||
@pages = Page.all.values
|
||||
end
|
||||
|
||||
# GET /merged/pages/1
|
||||
@ -13,7 +13,6 @@ module Merged
|
||||
|
||||
# GET /merged/pages/new
|
||||
def new
|
||||
@page = Merged::Page.new
|
||||
end
|
||||
|
||||
# GET /merged/pages/1/edit
|
||||
@ -49,7 +48,7 @@ module Merged
|
||||
private
|
||||
# Use callbacks to share common setup or constraints between actions.
|
||||
def set_page
|
||||
@page = Merged::Page.find(params[:id])
|
||||
@page = Page.find(params[:id])
|
||||
end
|
||||
|
||||
# Only allow a list of trusted parameters through.
|
||||
|
@ -1,8 +1,11 @@
|
||||
module Merged
|
||||
class SectionsController < MergedController
|
||||
before_action :set_page
|
||||
before_action :set_section , except: :index
|
||||
#, 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
|
||||
@ -15,24 +18,24 @@ module Merged
|
||||
|
||||
def set_image
|
||||
@section.content["image"] = params[:image]
|
||||
@page.save
|
||||
redirect_to page_section_url(@page.id,@section.id)
|
||||
@section.save
|
||||
redirect_to section_url(@section.id)
|
||||
end
|
||||
|
||||
def set_template
|
||||
template = params[:template]
|
||||
raise "no template given" if template.blank?
|
||||
@section.content["template"] = template
|
||||
@page.save
|
||||
redirect_to page_section_url(@page.id,@section.id)
|
||||
@section.save
|
||||
redirect_to section_url(@section.id)
|
||||
end
|
||||
|
||||
def set_card_template
|
||||
card_template = params[:card_template]
|
||||
raise "no card template given" if card_template.blank?
|
||||
@section.content["card_template"] = card_template
|
||||
@page.save
|
||||
redirect_to page_section_url(@page.id,@section.id)
|
||||
@section.save
|
||||
redirect_to section_url(@section.id)
|
||||
end
|
||||
|
||||
def update
|
||||
@ -43,15 +46,13 @@ module Merged
|
||||
puts "updating:#{key}=#{params[key]}"
|
||||
end
|
||||
end
|
||||
@page.save
|
||||
redirect_to :page_section
|
||||
@section.save
|
||||
redirect_to :section
|
||||
end
|
||||
|
||||
private
|
||||
def set_page
|
||||
@page = Page.find(params[:page_id])
|
||||
section_id = params[:id] || params[:section_id]
|
||||
@section = @page.find_section( section_id )
|
||||
def set_section
|
||||
@section = Section.find( params[:id] || params[:section_id] )
|
||||
end
|
||||
|
||||
end
|
||||
|
Reference in New Issue
Block a user