"Ugly URLs" don't work with map.resources?


I’ve a Course model in my application and so my routes file contains
the standard:

map.resources :courses

and then of course:

map.connect ‘:controller/:action/:id.:format’
map.connect ‘:controller/:action/:id’

URLs like “www.example.com/courses/1;edit” and “www.example.com/
courses/edit/1” work fine, but when I use something like this
www.example.com/courses/edit?id=1” it doesn’t work. The “show” action
is called instead of “edit”. Removing map.resources line fixes it of
course, but I was wondering if there’s a way to have the cake and eat
it too?

I need the “www.example.com/courses/edit?id=1” format to be able to
send a GET request through a form with a select_tag setting an id. So
I’d like to do something like this:

Edit course
<% form_for(:course, :url => {:controller => ‘courses’, :action =>
:html => { :method => :get }) do |f| %>
<%= select_tag ‘id’,
options_from_collection_for_select(Course.find(:all), ‘id’,
‘name_and_dates’) %>
<%= submit_tag ‘Go!’ %>
<% end -%>

So, alternatively, is there any other way to do this (and make it
degradable to non-JS browsers)?


This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.

| Privacy Policy | Terms of Service | Remote Ruby Jobs