私は持っている...
レーキルート:
edit_report_question
GET
/reports/:report_id/questions/:id/edit(.:format)
questions#edit
question_controller.rb:
def edit
@report = Report.find(params[:report_id])
@questions = @report.questions.find(params[:id])
end
report.rb:
has_many :questions
question.rb:
belongs_to :report
edit.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 の undefined method `model_name'」というエラーが表示されるのでしょうか?
注:現在、各レポートには多くの質問がありますが、最終的にはレポートに多くの質問を含め、多くの質問に属させたいと考えています。