What is the proper way to create lists?

Hey guys,

I have a Bookmark model.

I would like to have a *List *model. So my users can create Bookmark

I created a List scaffold with this command

rails generate scaffold List title:string

  1. A List can have many bookmarks
  2. A Bookmark can have many lists.

Can someone help me to create List Bookmark relationship.? It would be
awesome if you can give me some resources to learn.


You should use a has_and_belongs_to_many association.
Here is a nice code sample:

Don,t forget to create a middle table “bookmasks_lists”.

If the asociation has any attributes you shold use “has_many :through
association” instead.

2014-03-10 15:02 GMT-03:00 Giri [email protected]:


If list can have many bookmarks and bookmark can be included in many
lists, you should use has_and_belongs_to_many, or has_many :through

You can learn more in these articles

Alex Vasyutin
Skype: alexander.vasyutin