Thursday, November 29, 2012

[Rails] Issue with passing parameter to action using link_to

Hi,

I have a controller named Users with index action.

def index
    puts "************* #{params[:city]}"
    ...
    ...
end

From the view,
link_to(:city, list_users_with_city_path(:city => city.name))

But when I click on this link, it doesn't prints out anything for the params. All the "*" are being printed. The url in the browser displays,

localhost:3000/users?city=delhi

Instead when I create a new route, get '/users/:city' => 'users#index', :as => list_users_with_city
This works fine. I get proper output.

What could be the problem?




--
You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group.
To post to this group, send email to rubyonrails-talk@googlegroups.com.
To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msg/rubyonrails-talk/-/lpsqYbWtC0cJ.
For more options, visit https://groups.google.com/groups/opt_out.
 
 

0 Comments:

Post a Comment

Subscribe to Post Comments [Atom]

<< Home


Real Estate