1

I have QuestionsController and TrueFalseQuestionsController. I built a form to create question true/false, this is my form:

<%= simple_form_for @question, defaults: { error: false } do |question_form| %>
  <fieldset>
    <legend>Question</legend>
    <%= render 'shared/error_messages', object: question_form.object %>
    <%= question_form.input :content, input_html: { rows: 3, class: 'span6' } %>
    <%= question_form.input :mark, input_html: { class: 'span1' } %>
    <%= question_form.association :topic %>

    <%= question_form.simple_fields_for :answers do |answer_form| %>    
      <%= answer_form.input :correct,
            collection: [[true, 'True'], [false, 'False']],
            as: :radio_buttons,
            label: 'Answer',
            value_method: :first,
            label_method: :last,
            item_wrapper_class: 'inline' %>
    <% end %>
  </fieldset>

    <%= question_form.button :submit, class: 'new_resource' %>
<% end %>

Now when I submit the form, it uses create action in QuestionsController, so how can I specify form to use create action in TrueFalseQuestionsController?

4

1 回答 1

0

你又来了:),正如我在上一个问题中告诉你的那样,如果你为这三种类型的问题准备了三个部分,只需在每个部分中做不同的事情。我假设你已经在 routes.rb 中设置了嵌套路由

例如,在真假问题表格中,您可以这样做

form_for @question, :url=>true_false_questions_path do |f| 

其他人也这样做。

于 2012-10-30T09:48:34.727 回答