开发者

Ruby on Rails: How do I pass variables with observer_form?

开发者 https://www.devze.com 2023-01-06 19:52 出处:网络
I have <%= observe_field :tb_search, :frequency=>0.5, :update=>\'reports\', :url=>{ :action=>\'filter_reports\',

I have

    <%= observe_field :tb_search, 
    :frequency=>0.5, :update=>'reports',
    :url=>{
        :action=>'filter_reports',
       开发者_如何学Go :only_path=>false,
        :user=>@user.id},
    :with=>"'search='+encodeURIComponent(value)" %>

but on the controller side, params[:user] is nil. I did a

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

in the responding method in controller to prove to myself that it was nil.

any ideas?


With this helper I believe you need to pass all params through the :with option. Something like:

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

精彩评论

暂无评论...
验证码 换一张
取 消