i have an app with a SearchController and index action.
on the views i have index.html.erb and in the file i wrote this code:
<h1>Search#index</h1>
<%= form_tag(search_path, :method => "get") do %>
<%= label_tag(:q, "Search for:") %>
<%= text_field_tag(:q) %>
<%= submit_tag("Search") %>
<% end %>
and my routes file is this:
Ti::Application.routes.draw do
get "search/index"
root :to => "search#index"
end
when i runed the app i got a error that i did not set the “search path” on the routes file so i added this line:
map.search "search", :controller => "search"
but that line dont work, what shoud i write ?
10x
Try:
And don’t be afraid to have a play in your routes.rb file. I’d really recommend spending a couple of hours adding dummy routes and running:
and see what comes out the other end. If you’re just starting out with routes in Rails 3 you should check out this page, it’s a pretty good starting point.
http://www.engineyard.com/blog/2010/the-lowdown-on-routes-in-rails-3/