I’m using named routes in my ruby code. I come from the phpworld where you’ll pass information using $_GET and $_POST. I was wondering if there’s a way to put this into the routes.rb like this:
map.with_options :controller => 'test' do |m|
m.someurl 'someurl?search=someterm', :action => 'index'
end
Currently it’s returning can't convert Hash into String. Thanks!
Justin
If you want to just use a Query String, you don’t need to tell your route at all. The params object will contain any passed parameters.
Then when you use the helper method:
some_url_path(:search=> “someterm”)
Will create the query string value for you.
However, if you want to pass a parameter to a controller, you can bind them in your route:
In your controller you can then access:
In your case this would up being something like:
The Rails Routing Guide provides an excellent overview on the subject.