inossidabile / protector

Comfortable (seriously) white-list security restrictions for models on a field level
MIT License
270 stars 31 forks source link

Can't disable strong params #16

Closed anazar closed 11 years ago

anazar commented 11 years ago

This config.protector.strong_parameters = false in application.rb is giving this error method_missing': undefined methodprotector' for #Rails::Application::Configuration:0x007fccb43d8410 (NoMethodError)

I also tried creating an initializer which failed as well.

fdeschenes commented 11 years ago

@anazar - You need to use Protector.config.strong_parameters = false instead – and I'd suggested placing it in config/initializers/protector.rb instead of in config/application.rb. Here's what your file should look like:

# config/initializers/protector.rb
Protector.config.strong_parameters = false
inossidabile commented 11 years ago

@fdeschenes not really true. @anazar is right – there should be ability to make it using Rails config, Protector has all appropriate accessors for that. I'll check it right now.

fdeschenes commented 11 years ago

@inossidabile My bad – that said, the README suggests using Protector.config.strong_parameters = false which is why I suggested the initializer.

inossidabile commented 11 years ago

I have just generated an empty Rails application. Here's how my application.rb looks:

require File.expand_path('../boot', __FILE__)

require 'rails/all'

# Require the gems listed in Gemfile, including any gems
# you've limited to :test, :development, or :production.
Bundler.require(:default, Rails.env)

module Foobar
  class Application < Rails::Application
    config.protector.strong_parameters = false
    # Settings in config/environments/* take precedence over those specified here.
    # Application configuration should go into files in config/initializers
    # -- all .rb files in that directory are automatically loaded.

    # Set Time.zone default to the specified zone and make Active Record auto-convert to this zone.
    # Run "rake -D time" for a list of tasks for finding time zone names. Default is UTC.
    # config.time_zone = 'Central Time (US & Canada)'

    # The default locale is :en and all translations from config/locales/*.rb,yml are auto loaded.
    # config.i18n.load_path += Dir[Rails.root.join('my', 'locales', '*.{rb,yml}').to_s]
    # config.i18n.default_locale = :de
  end
end

It works properly. Which version of Rails are you using?

inossidabile commented 11 years ago

@fdeschenes https://github.com/inossidabile/protector/blob/master/README.md#options, last paragraph:

Protector features basic Rails integration so you can assign options using `config.protector.option = value` at your `config/*.rb`.

So you should probably get rid of initializer too :yum:

anazar commented 11 years ago

I'm using rails4... i tried both methods...

I can't put it in the initializer file or application.rb.

inossidabile commented 11 years ago

That said – it works for me. Can you show me your Gemfile and actual initializer (or config) code?

inossidabile commented 11 years ago

any news so far?

inossidabile commented 11 years ago

Closing until more details provided.