Fix managing widget cards for homepage
The condition `params[:page_id] != 0` didn't work properly when editing the homepage because in that case the parameter was `nil`, and the line `SiteCustomization::Page.find(@card.site_customization_page_id)` raised an exception because it couldn't find a page with a `nil` ID. Fixing the issue while maintaining the check against `0` lead to complex code, and so allowing `nil` in the database and assuming cards with no `site_customization_page_id` belonged in the homepage seemed to be the easiest solution.
This commit is contained in:
@@ -1,5 +1,5 @@
|
||||
class AddSiteCustomizationPageToWidgetCards < ActiveRecord::Migration
|
||||
def change
|
||||
add_reference :widget_cards, :site_customization_page, index: true, default: 0
|
||||
add_reference :widget_cards, :site_customization_page, index: true
|
||||
end
|
||||
end
|
||||
@@ -1503,7 +1503,7 @@ ActiveRecord::Schema.define(version: 20181218164126) do
|
||||
t.boolean "header", default: false
|
||||
t.datetime "created_at", null: false
|
||||
t.datetime "updated_at", null: false
|
||||
t.integer "site_customization_page_id", default: 0
|
||||
t.integer "site_customization_page_id"
|
||||
end
|
||||
|
||||
add_index "widget_cards", ["site_customization_page_id"], name: "index_widget_cards_on_site_customization_page_id", using: :btree
|
||||
|
||||
Reference in New Issue
Block a user