Question

I am using Ruby on Rails v3.2.2 and I would like to handle an array of symbols so to pass its values to the attr_accessible method as well as it should be made. That is, I have:

attr_array = [:one, :two, ...]

If I use:

attr_accessible attr_array

I get the following:

self.accessible_attributes.inspect
# => #<ActiveModel::MassAssignmentSecurity::WhiteList: {"[:one, :two, ..."]}>

However, I would like to get:

# => #<ActiveModel::MassAssignmentSecurity::WhiteList: {"one", "two", "..."}>

as well as it should be made.

How can I make that?

Était-ce utile?

La solution

Just like this :

attr_accessible *array
Licencié sous: CC-BY-SA avec attribution
Non affilié à StackOverflow
scroll top