Permalink
Browse files

Handle whitelist configuration before active_record.set_configs

Add an initializer block that runs before the active_record.set_configs
initializer so that Active Record doesn't blow up trying to set the
whitelist_attributes configuration variable.

Closes #5
  • Loading branch information...
1 parent 2da542e commit 89ddff5a0185ccc4ced337359d175ddfeb6efe53 @pixeltrix pixeltrix committed Nov 9, 2012
Showing with 2 additions and 0 deletions.
  1. +2 −0 lib/protected_attributes/railtie.rb
@@ -3,7 +3,9 @@ class Railtie < ::Rails::Railtie
config.before_configuration do |app|
config.action_controller.permit_all_parameters = true
config.active_record.whitelist_attributes = true if config.respond_to?(:active_record)
+ end
+ initializer "protected_attributes.whitelist_attributes", :before => "active_record.set_configs" do |app|
ActiveSupport.on_load(:active_record) do
if app.config.respond_to?(:active_record) && app.config.active_record.delete(:whitelist_attributes)
attr_accessible(nil)

0 comments on commit 89ddff5

Please sign in to comment.