model problems in vote system
I have three models Vote, Option and Number. I set up an index to input voting information such as title and description. How do I store the number of votes (in the Number model) using radio buttons?
My models have the following attributes:
Vote: name, description
Option: vote_id, content
Number: option_id, content (integer)
here is my edit.html i want to add vote-number function in this html,but i don't know how.so Can You give me some ideas to finish it? ^_^.i'm new in rails ,and thank you very much for helping me !!
<p id="notice"><%= notice %></p>
<p>
<b>Name:</b>
<%= @vote.name %>
</p>
<p>
<b>Description:</b>
<%= @vote.description %>
</p>
<% for option in @vote.options %>
<%=h option.content %><br />
<% end %>
<%= link_to 'Back',开发者_如何学Python votes_path %>
This might point you in the right direction:
http://railscasts.com/episodes/196-nested-model-form-part-1
You'll want to use *fields_for* within your input form, and pass your second model to it. Rails should take care of the magic in the backend if your model association relationships (belongs_to, has_many etc.) have been set up correctly.
精彩评论