Mass Security Assignment to undefined method `attr_accessible

737 views Asked by At

I'm using Rails 3.2.13 and Refinery with Inquiries gem. I needed to add a field to the contact form provided by the Inquiries gem; however, I get this error

     “WARNING: Can't mass-assign protected attributes”

I had read to NOT disable the whitelist in the application.rb. So I did

  config.active_record.whitelist_attributes = false

It still didn't work. So I tried to go ahead and add the attr_accessible to

/config/initializers/refinery/inquiries.rb

  Refinery::Inquiries.configure do |config|
  attr_accessible :location
  end

But now I get this error

/config/initializers/refinery/inquiries.rb:7:in <top (required)>': undefined methodattr_accessible' for main:Object (NoMethodError)

I just need to get this form field to work. Any hints!? Please!?

2

There are 2 answers

0
Miotsu On BEST ANSWER
attr_accessible 

is to be used in a model's definition, not in a block. Which object is your from writing into?

0
nil On

Had to run rake refinery:override model=refinery/inquiries/*

added attr_accesible option in here. Thanks!