File: railtie.rb

package info (click to toggle)
ruby-protected-attributes 1.0.8-2
  • links: PTS, VCS
  • area: main
  • in suites: jessie, jessie-kfreebsd
  • size: 304 kB
  • ctags: 382
  • sloc: ruby: 1,977; makefile: 2
file content (18 lines) | stat: -rw-r--r-- 617 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
require 'rails/railtie'

module ProtectedAttributes
  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.active_record", :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)
        end
      end
    end
  end
end