NullVoxPopuli
NullVoxPopuli

Reputation: 65173

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

I have

    <%= observe_field :tb_search, 
    :frequency=>0.5, :update=>'reports',
    :url=>{
        :action=>'filter_reports',
        :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?

Upvotes: 0

Views: 93

Answers (1)

bjg
bjg

Reputation: 7477

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}"

Upvotes: 1

Related Questions