What is the proper way to set-up routing for a url like ''/blog/2006/10'' (/blog/year/month) using the simply_restful support in edge rails? I''m trying to keep everything within the confines of REST, but I need to be able to paginate through months in my index view. I''m just not sure how I should set-up my resource in routes.rb so that it passes the year and month to my controller. Any help yoou can give me is totally appreciated. -- Posted via http://www.ruby-forum.com/. --~--~---------~--~----~------------~-------~--~----~ 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-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk -~----------~----~----~----~------~----~------~--~---
Zack Chandler
2006-Oct-29 16:39 UTC
Re: Proper way to route ''date'' urls using simply_restful
On 10/29/06, Andrew Hite <rails-mailing-list-ARtvInVfO7ksV2N9l4h3zg@public.gmane.org> wrote:> > What is the proper way to set-up routing for a url like ''/blog/2006/10'' > (/blog/year/month) using the simply_restful support in edge rails? I''m > trying to keep everything within the confines of REST, but I need to be > able to paginate through months in my index view. I''m just not sure how > I should set-up my resource in routes.rb so that it passes the year and > month to my controller. > > Any help yoou can give me is totally appreciated. > > -- > Posted via http://www.ruby-forum.com/. > > > >Andrew, As I understand it you have multiple blogs that you would like to RESTify but you need another route mapping... just use REST plus one extra route like this: map.resources :blogs map.connect ''blogs/:year/:month/:day'', :year => nil, :month => nil, :day => nil, :requirements => { :year => /\d{4}/, :month => /\d{1,2}/, :day => /\d{1,2}/ }, :controller => ''blogs'', :action => ''index'' Then check in index action for params. If present, add conditions to Blog.find(...) as needed. Check article_controller.rb in the mephisto source for a good example of this. Hope this helps, -- Zack Chandler http://depixelate.com --~--~---------~--~----~------------~-------~--~----~ 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-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk -~----------~----~----~----~------~----~------~--~---