On Dec 7, 2009, at 2:56 PM, Clarice wrote:
> Hi everyone, first e-mail here :)
>
> I have the following in my routes.rb file.
>
> map.connect ''posts/index/:page'',
> :controller => ''posts'',
> :action => ''index'',
> :requirements => {:page => /\d+/ },
> :page => nil
> end
>
> Does :requirements => {:page => /\d+/ } mean that if the :page
> parameter is empty this rule should not work?
>
> Thanks in advance!
Yup! You probably want two routes:
map.connect ''posts/index/:page'',
:controller => ''posts'',
:action => ''index'',
:requirements => {:page => /\d+/ }
map.connect ''posts/index'',
:controller => ''posts'',
:action => ''index'',
:page => nil
Or more succinctly:
map.with_options(:controller => ''posts'', :action =>
''index'') do |
post_index|
post_index.connect ''posts/index/:page'', :requirements =>
{:page => /
\d+/}
post_index.connect ''posts/index'', :page => nil
end
-Rob
Rob Biedenharn http://agileconsultingllc.com
Rob-xa9cJyRlE0mWcWVYNo9pwxS2lgjeYSpx@public.gmane.org
--
You received this message because you are subscribed to the Google Groups
"Ruby on Rails: Talk" group.
To post to this group, send email to
rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org
To unsubscribe from this group, send email to
rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org
For more options, visit this group at
http://groups.google.com/group/rubyonrails-talk?hl=en.