operator_index.htmlで:cosmo_idと:operatorに値を入れ、一覧表示もしたいのですが、
以下のエラーが出てしまいます。
ActionController::ParameterMissing in OperatorsController#operator_index
param is missing or the value is empty: operators
Ruby
1Extracted source (around line #70): 2 369 def operator_index_params 470 params.require(:operators).permit(:id, :created_at,:updated_at, :cosmo_id,:operator) 571 end
現在のコードは以下になります。
Ruby
1 def create 2 @operator = Operator.new(operator_index_params) 3 if @operator.save 4 # session[:cosmo_id] 5 # flash[:notice] = "ユーザー登録が完了しました" 6 redirect_to("/operator_index") 7 else 8 render("/operator_index") 9 end 10 end 11 ....... 12 def operator_index_params 13 params.require(:operators).permit(:id, :created_at,:updated_at, :cosmo_id,:operator) 14 end
HTML
1<h1>operator_index</h1> 2<%= form_for(@operator) do |f| %> 3 <div> 4 <%= f.label :cosmo_id %> 5 <%= f.text_field :cosmo_id %> 6 </div> 7 8 <div> 9 <%= f.label :operator %> 10 <%= f.text_field :operator %> 11 </div> 12 13 <div> 14 <%= f.submit %> 15 </div> 16<% end %> 17 18<div> 19 <% @operators.each do |operator| %> 20 <div> 21 <%= operator.cosmo_id %> 22 <%= operator.operator %> 23 </div> 24 <% end %> 25</div>
データを保存し、一覧表示するやり方をご教授いただけると幸いです。
回答1件
あなたの回答
tips
プレビュー
バッドをするには、ログインかつ
こちらの条件を満たす必要があります。
2017/07/22 09:17