Rails 3 routes and using GET to create clean URLs?
Posted
by
Hard-Boiled Wonderland
on Stack Overflow
See other posts from Stack Overflow
or by Hard-Boiled Wonderland
Published on 2010-12-30T15:06:57Z
Indexed on
2010/12/30
15:54 UTC
Read the original article
Hit count: 235
I am a little confused with the routes in Rails 3 as I am just starting to learn the language. I have a form generated here:
<%= form_tag towns_path, :method => "get" do %>
<%= label_tag :name, "Search for:" %>
<%= text_field_tag :name, params[:name] %>
<%= submit_tag "Search" %>
<% end %>
Then in my routes:
get "towns/autocomplete_town_name"
get "home/autocomplete_town_name"
match 'towns' => 'towns#index'
match 'towns/:name' => 'towns#index'
resources :towns, :module => "town"
resources :businesses, :module => "business"
root :to => "home#index"
So why when submitting the form do I get the URL:
/towns?utf8=?&name=townname&commit=Search
So the question is how do I make that url into a clean url like:
/towns/townname
Thanks,
Andrew
© Stack Overflow or respective owner