Skip to content

Commit

Permalink
Extract permitted params lists
Browse files Browse the repository at this point in the history
So they can be easily extended by (...wait for it...) _extensions_
  • Loading branch information
matiasgarciaisaia authored and bricesanchez committed Jan 17, 2018
1 parent 4e67060 commit 8baa341
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -23,9 +23,13 @@ def destroy

protected
def new_page_part_params
params.except(:part_index).permit(:title, :slug, :body, :locale)
params.except(:part_index).permit(permitted_new_page_part_params)
end

private
def permitted_new_page_part_params
[:title, :slug, :body, :locale]
end
end
end
end
12 changes: 10 additions & 2 deletions pages/app/controllers/refinery/admin/pages_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ def page_params
end

def new_page_params
params.permit(:parent_id, :view_template, :layout_template)
params.permit(permitted_new_page_params)
end

private
Expand All @@ -100,10 +100,18 @@ def permitted_page_params
[
:browser_title, :draft, :link_url, :menu_title, :meta_description,
:parent_id, :skip_to_first_child, :show_in_menu, :title, :view_template,
:layout_template, :custom_slug, parts_attributes: [:id, :title, :slug, :body, :position]
:layout_template, :custom_slug, parts_attributes: permitted_parts_attributes_params
]
end

def permitted_parts_attributes_params
[:id, :title, :slug, :body, :position]
end

def permitted_new_page_params
[:parent_id, :view_template, :layout_template]
end

def save_and_continue_locals(page)
nested_url = page.nested_url
{
Expand Down

0 comments on commit 8baa341

Please sign in to comment.