我有...
耙路线:
edit_report_question
GET
/reports/:report_id/questions/:id/edit(.:format)
questions#edit
questions_controller.rb:
def edit
@report = Report.find(params[:report_id])
@questions = @report.questions.find(params[:id])
end
报告.rb:
has_many :questions
问题.rb:
belongs_to :report
编辑.html.haml:
.textbox
= render "shared/notice"
%h1 Edit Question
= render "form"
= render "actions"
_form.html.haml:
= simple_form_for [@report, @question] do |f|
= f.error_notification
= f.association :report
= f.input :description
= f.input :blueprint_name, :label => "Blueprint Name"
= f.input :blueprint_url, :label => "Blueprint URL"
= f.association :element, :label => "Website Element"
= f.association :standard
- if params[:action]=~ /edit/
= f.association :fields, :as => :select
= f.button :submit, :id => 'submit_question'
参数:
{"action"=>"edit", "controller"=>"questions", "report_id"=>"1", "id"=>"1"}
那么为什么我会收到“NilClass:Class 的未定义方法 `model_name'”错误?
注意:目前每个报告都有很多问题,但最终我希望报告有很多并且属于很多问题。