1

強力なパラメーターを使用していますが、次のフォームを保存しようとすると、次のメッセージが表示されます。

# '<'VisitsController:0x007fa88deec428'>' の未定義のメソッド `household_params'

世帯コントローラーではなく訪問コントローラーを使用しているため、混乱しています。訪問は、以下に示すように世帯に関連付けられており、次のコードでビューを呼び出します。

= link_to 'New Visit', {controller: 'visits', action: 'new', 
household_id: household.id, method: 'post'}, class: 'btn btn-primary'

フォームは次のとおりです。

%h3 Household: #{household.name}
%h4 Household Members: #{household.neighbors.count}
%h4 Visits: #{household.visits.count}
= simple_form_for visit do |f|
  = f.input  :visited_on,     :label => 'Visited On', as: :date_picker, input_html: { class: 'span2' }
  = f.input  :starch,         :label => false,  collection: ['Beans','Rice','Potatoes'],selected: 'Beans'
  = f.input  :cereal,         :label => false,  collection: ['Cereal','Grits','Oatmeal']
  = f.input  :option1,        :label => false,  collection: ['Peanut Butter Jelly', 'Deserts','Baby Fromula'], prompt: 'Options'
  = f.input  :items_received, :label => 'Special Needs',input_html: {rows: 4, class: 'span9' }
  = f.input  :notes,          :label => 'Notes',input_html: {rows: 4, class: 'span9' }
  = f.button :submit, :class => 'btn-primary', :label=> 'Save' 

このフォームは、世帯に関する情報を表示する 3 行がなくても正常に機能します。

私はstrong_parametersが混乱していると思っています

4

0 に答える 0