I have established many to many relation with the help of this site.
I have added has_and_belongs_to_many in the model
Now I want to display data from that object on the screen
I assume I should do it in the html.erb
lets say that I want it on the index form and in the edit/new form
how can I present that? thanks.
EDIT:
I have two objects :
i.e. person and states - A person can have many states)
I want to have a screen where I could present all the states of the person and another screen where I can add him another states.
as I mentioned I created rb scripts like this (for both)
class CreateStates < ActiveRecord::Migration
def change
create_table :states do |t|
t.string :name
t.timestamps
end
end
end
and a join table
def up
create_table 'persons_states', :id => false do |t|
t.integer :persons_id
t.integer :states_id
end
end and in the model added has_and_belongs_to_many :ingredients
How do I update my code of ther gui? thank