Hi all I want to implement url aliasing on my site...say suppose my url is domain/blog/1 instead of that i want domain/blog/title-of-that-blog Is there any method how i can remove Id and put the title instead Thanks a lot Dhaval Parikh -- 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?hl=en -~----------~----~----~----~------~----~------~--~---
Dhaval Parikh wrote:> Hi all > > I want to implement url aliasing on my site...say suppose my url is > > domain/blog/1 instead of that i want domain/blog/title-of-that-blog Is > there any method how i can remove Id and put the title instead > > Thanks a lot > > Dhaval ParikhYou will have to create a slug or a permalink column in your e.g. Article model, make sure it is unique, then you have a route like #routes.rb map.article ''blog/:permalink'' , :controller=>''article'', :action=>''show'' #article_controller.rb def show @article = Article.find_by_permalink(params[:permalink]) render :template => ''not_found'', :status => 404 unless @article end -- 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?hl=en -~----------~----~----~----~------~----~------~--~---
but in that case i need to route for each and every controller and its methods..which i dont want... -- 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?hl=en -~----------~----~----~----~------~----~------~--~---
I think you can do something like map.resources '':controller/:action/:permalink'' , :controller=>'':controller'', :action=>'':action'', and optionally maybe even :id => :permalink. I don''t know about if and where you should put the quotes, if any, though. On Jan 30, 6:45 am, Dhaval Parikh <rails-mailing-l...-ARtvInVfO7ksV2N9l4h3zg@public.gmane.org> wrote:> but in that case i need to route for each and every controller and its > methods..which i dont want... > -- > Posted viahttp://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@googlegroups.com For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---