I have following tables with following models:
users(id, role_id) has_many :entries
categories(id, category_name) has_many :entries
entries(id, category_id, user_id) belongs_to :user, belongs_to
:category, has_one :storage
storages(id, title, content, entry_id)* belongs_to :entry*,
has_one
:vote
votes(id, count, storage_id) belongs_to :storage
Now, when user create new entry(through form) few things must happen:
- New row in entry table will be created(with already
existinguser_id and category_id)
- New row in storages table will be created(title and content of
the
post with above entry_id)
- New row in votes table(with above storage_id, count is default
0)
Form for creating new entry have, combo box for selecting category(like:
“Pictures”, “Movies”, etc), text box for title and text-area for
content.
I followed many tutorials and documentation like:
#196 Nested Model Form Part 1 - RailsCasts and
ActiveRecord::NestedAttributes::ClassMethods
but can’t get it how to work.