Sure, Thank you very much.
reports_controller.rb
def new
@report = Report.new
@report.answer_singles.build
respond_to do |format|
format.html # new.html.erb
format.json { render :json => @report }
end
end
_form.html.erb
<%= form_for(@report) do |f| %>
<% if @report.errors.any? %>
<div id="error_explanation">
<h2><%= pluralize(@report.errors.count, "error") %> prohibited
this report from being saved:</h2>
<ul>
<% @report.errors.full_messages.each do |msg| %>
<li><%= msg %></li>
<% end %>
</ul>
</div>
<% end %>
<div class="field">
<%= f.label :project_id, "Project Runner" %><br />
<%= f.select :project_id, Project.all.collect {|d|
[Project::P_PARTNER[d.partner], d.partner]} %>
</div>
<div class="field">
<%= f.label :finalized %><br />
<%= f.select :finalized, [["Yes", true], ["No", false]] %>
</div>
<div class="field">
<%= f.label :emails %><br />
<%= f.number_field :emails %>
</div>
<div class="question">
<% QuestionSingle.all.each_with_index do |question, index| %>
<p><%= index+1 %>. <%= question.content %></p>
<%= f.fields_for :answer_singles, {:question_single_id =>
:index} do |answer| %>
<%= answer.text_area :content, {:question_single_id => :index}
%>
<% end %>
<% end %>
</div>
<div class="actions">
<%= f.submit %>
</div>
<% end %>
Others are just as the scaffold output (index, edit, new, show)
--
Posted via http://www.ruby-forum.com/.
--
You received this message because you are subscribed to the Google Groups "Ruby
on Rails: Talk" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to
[email protected].
For more options, visit this group at
http://groups.google.com/group/rubyonrails-talk?hl=en.