Hi there…
I have created a table and a join table
class CreateArrangements < ActiveRecord::Migration
def self.up
create_table :arrangements do |t|
t.column :name, :string
end
end
def self.down
drop_table :arrangements
end
end
Join table**********
class AddTableArragementUsers < ActiveRecord::Migration
def self.up
create_table :arrangements_users, :id => false do |t|
t.column :arrangement_id, :integer, :null => false
t.column :user_id, :integer, :null => false
end
add_index “arrangements_users”, “arrangement_id”
add_index “arrangements_users”, “user_id”
end
def self.down
end
end
In the user-edit-view page a put in the following code:
arrangement
<%= select_tag 'user[arrangement_ids][]',
options_from_collection_for_select(@arrangement, :id, :name,
@user.arrangements.collect{|arrangement| arrangement.id}),
{ :multiple => true, :size => 5 }%>
But i get the following error
You have a nil object when you didn’t expect it!
You might have expected an instance of Array.
The error occurred while evaluating nil.inject
Anyone idea?
Swoany