Use polymorphic routes to manage cards
We use a different logic to load the card depending on the controller we're using, and then share the rest of the code. This way we simplify the code a bit, since we don't have to check for the page_id parameter.
This commit is contained in:
@@ -227,7 +227,7 @@ namespace :admin do
|
||||
|
||||
namespace :site_customization do
|
||||
resources :pages, except: [:show] do
|
||||
resources :cards, only: [:index]
|
||||
resources :cards, except: [:show], as: :widget_cards
|
||||
end
|
||||
resources :images, only: [:index, :update, :destroy]
|
||||
resources :content_blocks, except: [:show]
|
||||
@@ -270,6 +270,10 @@ resolve "Audit" do |audit|
|
||||
[*resource_hierarchy_for(audit.associated || audit.auditable), audit]
|
||||
end
|
||||
|
||||
resolve "Widget::Card" do |card, options|
|
||||
[*resource_hierarchy_for(card.page), card]
|
||||
end
|
||||
|
||||
resolve "Budget::Group" do |group, options|
|
||||
[group.budget, :group, options.merge(id: group)]
|
||||
end
|
||||
|
||||
Reference in New Issue
Block a user