I am a beginner with Rails 3 programming and I have one problem with creating the right model.
Let's say there is an application to manage the bibliography of a book, that is manage the mapping for each chapter of the list of referenced articles. So for the article part I could have something like:
create_table :articles do |t|
t.string :title
t.text :content
...
On the bibliography side I would like to have a model like
create_table :bibliographies do |t|
t.string :chapter
t.text :ref
...
where ref
is actually an array of references to articles, so it would be managed via serialize
ActiveRecord method.
Ok, so now the issue is about how to make so that the elements of the array @bibliography.ref
are references (in Ruby sense) to several article_id
.
How do I model such a relationship, and what Rails 3 code should I write to express that? The thing that confuses me is that a single field of a single instance of @bibliography would reference to many @article.id .
Thanks in advance