DanC wrote in post #957019: > Hi Marnen, > >> Either use a regex to match the parameter (and then send it to a >> different controller action) or have a single controller action that >> runs both find_by_permalink and find_by_id. > > I have added this to the controller which seems to work well, as my > regex writing is weak.
Then get stronger! You don't need a very sophisticated regex, and no Ruby programmer can afford to be scared of regexes. http://www.rubular.com is your friend if you need help. Regexes are an essential tool in anything involving string processing -- and that includes Rails routing. Don't ignore them. > > @article = Article.find_by_permalink(params[:id]) > unless @article > @article = Article.find(params[:id]) > end That works, but you might want to move it to the model (perhaps in a find_by_permalink_or_id method). > > Thanks for the help. I really appreciate it. > > Dan Best, -- Marnen Laibow-Koser http://www.marnen.org mar...@marnen.org -- 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-t...@googlegroups.com. To unsubscribe from this group, send email to rubyonrails-talk+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.