raghus
2008-Dec-03 02:37 UTC
Single URL/route --> Different controller/action routing. Is this possible?
I am on Rails 2.0.2 I''ve set up routes.rb so that the URL http://mysite.com/username routes the user to :controller => ''foo'', :action => ''bar'' However, I am rev-ing my app and based on a flag in the Users table, I want some users to go to :controller => ''foo2'', :action => ''bar2'' while others should continue to get routed via :controller => ''foo'', :action => ''bar'' Is there any way at all to do this via routes.rb? Or some other hack? I still want the URL to be http://mysite.com/username 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 -~----------~----~----~----~------~----~------~--~---
Jeremy Weiskotten
2008-Dec-03 02:50 UTC
Re: Single URL/route --> Different controller/action routing. Is this possible?
raghus wrote:> I am on Rails 2.0.2 > > I''ve set up routes.rb so that the URL http://mysite.com/username > routes the user to :controller => ''foo'', :action => ''bar'' > > However, I am rev-ing my app and based on a flag in the Users table, I > want some users to go to :controller => ''foo2'', :action => ''bar2'' > while others should continue to get routed via :controller => > ''foo'', :action => ''bar'' > > Is there any way at all to do this via routes.rb? Or some other hack? > I still want the URL to be http://mysite.com/username > > ThanksYou can call any method from that action, including the code for another action, and then explicitly render whatever template you 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 -~----------~----~----~----~------~----~------~--~---
raghus
2008-Dec-08 07:22 UTC
Re: Single URL/route --> Different controller/action routing. Is this possible?
Yes, I can call action2 in action1 in foo controller. But how about when I need to call action2 which is in foo2 controller? How do I get around that? On Dec 2, 6:50 pm, Jeremy Weiskotten <rails-mailing-l...@andreas- s.net> wrote:> raghuswrote: > > I am on Rails 2.0.2 > > > I''ve set up routes.rb so that the URLhttp://mysite.com/username > > routes the user to :controller => ''foo'', :action => ''bar'' > > > However, I am rev-ing my app and based on a flag in the Users table, I > > want some users to go to :controller => ''foo2'', :action => ''bar2'' > > while others should continue to get routed via :controller => > > ''foo'', :action => ''bar'' > > > Is there any way at all to do this via routes.rb? Or some other hack? > > I still want the URL to behttp://mysite.com/username > > > Thanks > > You can call any method from that action, including the code for another > action, and then explicitly render whatever template you 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 -~----------~----~----~----~------~----~------~--~---
AndyV
2008-Dec-08 12:58 UTC
Re: Single URL/route --> Different controller/action routing. Is this possible?
Sounds like you want to look into using a before_filter. The job of the filter would be to redirect the action2 users to action2 and allow the rest to default to action1. On Dec 8, 2:22 am, raghus <raghu.sriniva...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> Yes, I can call action2 in action1 in foo controller. But how about > when I need to call action2 which is in foo2 controller? How do I get > around that? > > On Dec 2, 6:50 pm, Jeremy Weiskotten <rails-mailing-l...@andreas- > > s.net> wrote: > > raghuswrote: > > > I am on Rails 2.0.2 > > > > I''ve set up routes.rb so that the URLhttp://mysite.com/username > > > routes the user to :controller => ''foo'', :action => ''bar'' > > > > However, I am rev-ing my app and based on a flag in the Users table, I > > > want some users to go to :controller => ''foo2'', :action => ''bar2'' > > > while others should continue to get routed via :controller => > > > ''foo'', :action => ''bar'' > > > > Is there any way at all to do this via routes.rb? Or some other hack? > > > I still want the URL to behttp://mysite.com/username > > > > Thanks > > > You can call any method from that action, including the code for another > > action, and then explicitly render whatever template you 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-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
Raghu Srinivasan
2008-Dec-08 17:08 UTC
Re: Single URL/route --> Different controller/action routing. Is this possible?
AndyV - I could, but then some users would be *redirected* and see a different URL. I''d like everyone to see the same uniform URL : http://mysite.com/myusername On Mon, Dec 8, 2008 at 4:58 AM, AndyV <AndyVanasse-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> > Sounds like you want to look into using a before_filter. The job of > the filter would be to redirect the action2 users to action2 and allow > the rest to default to action1. > > On Dec 8, 2:22 am, raghus <raghu.sriniva...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote: > > Yes, I can call action2 in action1 in foo controller. But how about > > when I need to call action2 which is in foo2 controller? How do I get > > around that? > > > > On Dec 2, 6:50 pm, Jeremy Weiskotten <rails-mailing-l...@andreas- > > > > s.net> wrote: > > > raghuswrote: > > > > I am on Rails 2.0.2 > > > > > > I''ve set up routes.rb so that the URLhttp://mysite.com/username > > > > routes the user to :controller => ''foo'', :action => ''bar'' > > > > > > However, I am rev-ing my app and based on a flag in the Users table, > I > > > > want some users to go to :controller => ''foo2'', :action => ''bar2'' > > > > while others should continue to get routed via :controller => > > > > ''foo'', :action => ''bar'' > > > > > > Is there any way at all to do this via routes.rb? Or some other hack? > > > > I still want the URL to behttp://mysite.com/username > > > > > > Thanks > > > > > You can call any method from that action, including the code for > another > > > action, and then explicitly render whatever template you 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-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---