/ / Ruby on Rails:observer_formで変数を渡すにはどうすればよいですか? -ruby-on-rails

Ruby on Rails:observer_formで変数を渡すにはどうすればよいですか? -ルビーオンレール

私が持っています

    <%= observe_field :tb_search,
:frequency=>0.5, :update=>"reports",
:url=>{
:action=>"filter_reports",
:only_path=>false,
:user=>@user.id},
:with=>""search="+encodeURIComponent(value)" %>

ただし、コントローラー側では、params [:user]はnilです。 私はした

    puts "NTHDEONUTHDOEDEUU#{params[:user].nil?}||"

コントローラの応答メソッドで、それがゼロであることを自分で証明します。

何か案は?

回答:

回答№1は1

このヘルパーを使用すると、すべてのパラメータを :with オプション。何かのようなもの:

<%= observe_field :tb_search,
:frequency=>0.5, :update=>"reports",
:url=>{
:action=>"filter_reports",
:only_path=>false},
:with=>""search="+encodeURIComponent(value)+"&user="#{@user.id}"