Thanks for the suggestion. I do it something like this have a regular expression check on the request_uri and if it does not have the desired format just redirect to the same method with :id=>@movie
On May 20, 6:20 pm, Robert Walker <[email protected]> wrote: > Mr. Bless wrote: > > How to have a beautiful url like hulu. For example I like to have a > > url like this to show the movie detail with an id 1 as > >http://localhost:3000/movie/detail/1-movie_name > > First of all, beauty is in the eye of the beholder. Assuming that > /movie/1 and /movie/detail/1 are representing the exact same resource > then, to me, /movie/1-movie_name would be "more beautiful" than > /movie/detail/1-movie_name because it removes the redundancy of > /movie/detail. Now if the two are different resources (or > representations of a resource) then that's different. > > > If via a link, i can do this by writing the to_param method in movie > > model like this > > def to_param > > "#{id}-#{name}" > > end > > You probably better take care of URL escaping #{name}. > > > and a like like this > > <%=link_to > > 'Detail', :controller=>'movie',:action=>'detail',:id=>@movie %> > > This article might > help:http://jroller.com/obie/entry/seo_optimization_of_urls_in > > > How ever if the someone manually typehttp://localhost:3000/movie/1, > > I still need the url as shown previously. > > Again, I reiterate; Is /movie/1 the same representation of the same > resource as /movie/detail/1? Not that it matters, you can have as many > different URIs representing the same representation as you want. I'm > just attempting to clarify. > > I can think of two ways to change /movie/1 to show as > /movie/detail/1-movie_name if that's what the user enters into the > address field. 1. Have the movies_controller's "show" action redirect to > the other URI, or 2. Replace the address field value using JavaScript. > > How often do you expect an end user to type something > likehttp://example.com/movies/354. How would they have any idea what id goes > with what movie. So if they were to type in the URI directly, what > difference would it make? It would happen so rarely I doubt it would > have an adverse affect on your search engine results. Basically, people > aren't going to be doing that, so why engineer a solution for a problem > that doesn't really exist? > -- > 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 [email protected] To unsubscribe from this group, send email to [email protected] For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---

