On 10 November 2013 23:24, Srdjan Cengic wrote:
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 existing user_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:
http://railscasts.com/episodes/196-nested-model-form-part-1 and
http://api.rubyonrails.org/classes/ActiveRecord/NestedAttributes/ClassMethods.html#method-i-accepts_nested_attributes_for
but can't get it how to work.
First, I presume you have worked right through a good tutorial such as
railstutorial.org. If not then go and do that first, then you may be
able to answer the questions yourself.

If you have already done that then there is no point describing the
whole problem area with a long list of things you need to happen and
then just say you can't get it to work. Start with just one of the
things you want to do and get that working, then add the next
requirement. If you get stuck then come back with a description of
just the bit you can't get working, show us your code (for the bit
that does not work) and someone will surely help.

Colin

--
You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group.
To unsubscribe from this group and stop receiving emails from it, send an email to rubyonrails-talk+unsubscribe@googlegroups.com.
To post to this group, send email to rubyonrails-talk@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/rubyonrails-talk/CAL%3D0gLvLEZjCqj%2BY_y98Qx%2BrnC6vQJVtctqHY_%3D2i%3DrYECJ7%2BQ%40mail.gmail.com.
For more options, visit https://groups.google.com/groups/opt_out.

Search Discussions

Discussion Posts

Previous

Follow ups

Related Discussions

Discussion Navigation
viewthread | post
posts ‹ prev | 2 of 4 | next ›
Discussion Overview
grouprubyonrails-talk @
categoriesrubyonrails
postedNov 10, '13 at 11:24p
activeNov 11, '13 at 7:17p
posts4
users2
websiterubyonrails.org
irc#RubyOnRails

2 users in discussion

Srdjan Cengic: 3 posts Colin Law: 1 post

People

Translate

site design / logo © 2021 Grokbase