現在customer:callで1:多のアソシエーションを組んでおり、indexにて使われるパラメーターを引き継ぐ設定を行いたいのですが、それが出来ずに困っております。
内容は以下となります。
custometrcontroller
1 def index 2 @q = Customer.ransack(params[:q]) 3 @customers = @q.result 4 5 def show 6 @customer = Customer.find(params[:id]) 7 @call = Call.new(params[:q]) 8 #この部分が引き継がれない 9 @q = Customer.ransack(params[:q]).result 10 @prev_customer = @q.where("id < ?", @customer.id).last 11 @next_customer = @q.where("id > ?", @customer.id).first
index
1 <% @customers.each_with_index do |customer, index| %> 2 <tr> 3 <td><%= check_box_tag "deletes[#{customer.id}]", customer.id %></td> 4 <td><%= link_to customer.company, customer_path(customer,q: params[:q]&.permit!)%></td>
indexまで引き継がれていることはコンソールより確認済みです。
show
1<%= form_for ([@customer, @call]) do |f| %> 2<table> 3 <tbody> 4 <tr> 5 <th colspan="4">情報入力</th> 6 </tr> 7 <tr> 8 <th>ステータス</th> 9 <td><%= f.select(:statu, Call.StatuItems) %></td> 10 <th>再コール日時</th> 11 <td><%= f.datetime_field :time %></td> 12 </tr> 13 <tr> 14 <th>コメント</th> 15 <td colspan ="4" class="comment"><%= f.text_area :comment %></td> 16 </tr> 17 <tr> 18 <th colspan ="4"><%= f.submit %></th> 19 </tr> 20 </tbody> 21</table> 22<%end%> 23</div>
上記show内でcalls/newを作成する部分でparams[:q]が落ちてしまっているようです。
問題点は
show
1 def show 2 @customer = Customer.find(params[:id]) 3 @call = Call.new(params[:q])
の部分かと思っているのですが、解消出来ません。ご教示よろしくお願い致します。
ActiveModel::ForbiddenAttributesError (ActiveModel::ForbiddenAttributesError): app/controllers/customers_controller.rb:38:in `show'
バッドをするには、ログインかつ
こちらの条件を満たす必要があります。
2020/01/09 15:38
2020/01/09 21:00
2020/01/11 09:22
2020/01/11 09:39
2020/01/11 09:55
2020/01/11 11:48