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
lists.

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.

Thankyou

You should use a has_and_belongs_to_many association.
Here is a nice code sample:
http://guides.rubyonrails.org/association_basics.html#the-has-and-belongs-to-many-association

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

If the asociation has any attributes you shold use “has_many :through
association” instead.
http://guides.rubyonrails.org/association_basics.html#the-has-many-through-association

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

Hi,

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
associations.

You can learn more in these articles

http://guides.rubyonrails.org/association_basics.html#the-has-and-belongs-to-many-association
http://guides.rubyonrails.org/association_basics.html#the-has-many-through-association


Alex Vasyutin
Skype: alexander.vasyutin