Howdy. I''m new at Rails, but I think I understand the concept. Now I''m trying to map that to what I''ve done in the past with JSP/Java/Tomcat, and I have a specific problem I need to solve. A client likes to have his registered users have their own portal pages, like "thesite.com/someuser". In JSP I just added logic to the 404 handling such that if the path name "someuser" was a registered user in the database, then it would generate a page appropriate for them. Then, since this was a referral-based system (in terms of membership-benefits), if the visitor signed up on someuser''s page, someuser would get credit for it. How, in Rails, might such a thing be done? Would it be a hack like what I did on Tomcat in JSP, with 404 handling? Or is there some other facility for _faking_ pages that don''t exist? An example or other explanation of similar systems would be wonderful. Thanks! --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
blunte wrote: > A client likes to have his registered users have their own portal> pages, like "thesite.com/someuser". In JSP I just added logic to the > 404 handling such that if the path name "someuser" was a registered > user in the database, then it would generate a page appropriate for > them. Then, since this was a referral-based system (in terms of > membership-benefits), if the visitor signed up on someuser''s page, > someuser would get credit for it. > > How, in Rails, might such a thing be done? Would it be a hack like > what I did on Tomcat in JSP, with 404 handling? Or is there some > other facility for _faking_ pages that don''t exist? >I think you''d basically do it the same way. Map an action as the last-resort action and in there try to look up a user for the path. If you don''t find a user /then/ you do the 404. Read up on routes.rb... in fact, the comments in the generated routes.rb might be enough. b --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
On 5/7/07, Ben Munat <bmunat-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> > > blunte wrote: > > A client likes to have his registered users have their own portal > > pages, like "thesite.com/someuser". In JSP I just added logic to the > > 404 handling such that if the path name "someuser" was a registered > > user in the database, then it would generate a page appropriate for > > them. Then, since this was a referral-based system (in terms of > > membership-benefits), if the visitor signed up on someuser''s page, > > someuser would get credit for it. > > > > How, in Rails, might such a thing be done? Would it be a hack like > > what I did on Tomcat in JSP, with 404 handling? Or is there some > > other facility for _faking_ pages that don''t exist? > > > > I think you''d basically do it the same way. Map an action as the > last-resort action and in there try to look up a user for the path. If > you don''t find a user /then/ you do the 404. > > Read up on routes.rb... in fact, the comments in the generated routes.rb > might be enough. > > bYes have a look at doing this with routes. I hesitate to provide an actual route, but if you look at the general route map.connect ''/:controller/:action/:id'' This shows how you can construct a paraeterized url. map.connect ''/users/:username'', :controller => ''users'', :action => ''blah'' would provide the action in users -> blah with the param[:username] There is great docs on the rubysite for making really complex routes. HTH Cheers --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
In routes: map.connect ":id", :controller => "users", :action => "show" put this last. So all your other controllers take precedent Zach Inglis → Blog — http://www.zachinglis.com → Company — http://www.lt3media.com → Portfolio — http://portfolio.zachinglis.com On May 6, 2007, at 11:43 PM, blunte wrote:> > Howdy. > > I''m new at Rails, but I think I understand the concept. Now I''m > trying to map that to what I''ve done in the past with JSP/Java/Tomcat, > and I have a specific problem I need to solve. > > A client likes to have his registered users have their own portal > pages, like "thesite.com/someuser". In JSP I just added logic to the > 404 handling such that if the path name "someuser" was a registered > user in the database, then it would generate a page appropriate for > them. Then, since this was a referral-based system (in terms of > membership-benefits), if the visitor signed up on someuser''s page, > someuser would get credit for it. > > How, in Rails, might such a thing be done? Would it be a hack like > what I did on Tomcat in JSP, with 404 handling? Or is there some > other facility for _faking_ pages that don''t exist? > > An example or other explanation of similar systems would be wonderful. > > Thanks! > > > >--~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
Thanks for the good responses! I''ll look into "routes". --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---