In Ruby on Rails, the :id is only optional in routes.rb? How to tell optional vs not optional?
Posted
by Jian Lin
on Stack Overflow
See other posts from Stack Overflow
or by Jian Lin
Published on 2010-06-11T19:30:06Z
Indexed on
2010/06/11
19:32 UTC
Read the original article
Hit count: 181
In routes.rb
map.connect ':controller/:action/:id'
map.connect ':controller/:action/:id.:format'
but then
http://localhost:3000/foobars/alt
will work too. The params are:
{"action"=>"alt", "controller"=>"foobars"}
so looks like :id
is optional here. How can you tell it is optional vs not optional? Can you make it so that it is not optional in routes.rb?
© Stack Overflow or respective owner