HELP: array in a database field

It looks like you are trying to store the results of an association (has_many, habtm) in a field on a database table.

For example, if you are saving a user that has many roles, instead of having a “roles” field on your table, you would have a separate roles table and a roles_users table. The models would look like:

User - has_and_belongs_to_many :roles Roles - has_and_belongs_to_many :users

The view would look like:

<% for role in Role.find(:all) %> <input type=“checkbox” name=“role_ids

value=“<%= role.id %>”>
<% end %>

In the controller, on the create/update you use the convenient “role_ids” method of the user object, like:

@user=User.new(params[:user]) @user.role_ids = params[:role_ids]

Hope that helps.