3

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?

user12882
  • 4,702
  • 9
  • 39
  • 54

1 Answers1

10

Just like this :

attr_accessible *array
tomferon
  • 4,993
  • 1
  • 23
  • 44