I’m creating a address book.
A user can have many contacts.
In the user model, I put:
And in the contact model, I put:
To list all contacts, I search as following:
@user = User.find(session[:user_id])
<%= render(:partial => “contact”, :collection => @user.contacts)%>
To persist I am using the following code:
@contact = Contact.new(params[:contact])
@contact.user_id = session[:user_id]
It works, but is it the best solution?
Thanks in advance.