Hi, Lets assume we have an url, /controller1/action1. In the before filter, under certain conditions, I want to route it to /controller2/action2. without changing the url at the client side ie I donot want to use redirect. Please help. Regards, Pankaj -- 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-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
I would suggest using render instead of redirect. <%= render :partial => "controller2/action2" %> Checkout this page for more info: http://api.rubyonrails.org/classes/ActionView/Partials.html On Fri, Dec 11, 2009 at 9:15 AM, pankaj <pankajbhageria-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> Hi, > Lets assume we have an url, /controller1/action1. > In the before filter, under certain conditions, I want to route it > to /controller2/action2. without changing the url at the client side > ie I donot want to use redirect. Please help. > > Regards, > Pankaj > > -- > > 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-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org > To unsubscribe from this group, send email to > rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org<rubyonrails-talk%2Bunsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org> > . > For more options, visit this group at > http://groups.google.com/group/rubyonrails-talk?hl=en. > > >-- Andrei Erdoss -- 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-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
2009/12/11 pankaj <pankajbhageria-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>:> Hi, > Lets assume we have an url, /controller1/action1. > In the before filter, under certain conditions, I want to route it > to /controller2/action2. without changing the url at the client side > ie I donot want to use redirect. Please help. >class FooController < ApplicationController before_filter :maybe_redirect protected def maybe_redirect redirect_to your_url false end end -- 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-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@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.
Hey You can do Controller2.new.action2, but that''s not quite beautiful .. more over what your action2 will do after finish ? redirect ? render ? Regards On 11 déc, 08:15, pankaj <pankajbhage...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> Hi, > Lets assume we have an url, /controller1/action1. > In the before filter, under certain conditions, I want to route it > to /controller2/action2. without changing the url at the client side > ie I donot want to use redirect. Please help. > > Regards, > Pankaj-- 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-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@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.
You really need to give us more information to help. If you want just the layout from the other action, you can use render. However, render will not execute the code from the controller''s action method; it will only render the template. If you want to execute the code and truly redirect, I think you are stuck changing the url. Why do you need to do this? Let us know a little more of the situation and we might be able to give you a better solution. Good luck, Andrew On Dec 10, 11:15 pm, pankaj <pankajbhage...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> Hi, > Lets assume we have an url, /controller1/action1. > In the before filter, under certain conditions, I want to route it > to /controller2/action2. without changing the url at the client side > ie I donot want to use redirect. Please help. > > Regards, > Pankaj-- 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-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@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 your replies, I want to execute the new action as well as render the corresponding view, without changing the url. It is a case of dynamic routing. Following is the scenario: Every user can have their profile on the website, whose url is www.xyz.com/profileid Additionally there would be an option for the user to add a domain to point to their profile. So for example, my profile on the website is www.xyz.com/pankaj If I own a domain www.pankaj.com, and point it to www.xyz.com, then www.pankaj.com should take me to the page www.xyz.com/pankaj without changing the url. In the before filter function, I check if the url is not xyz.com, then it is mapped to the corresponding user, and then I need to go to the corresponding controller and action. Regards, Pankaj -- 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-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
can metal or rack be helpful in this? -- 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-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
On Dec 14, 10:49 pm, pankaj <pankajbhage...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> can metal or rack be helpful in this?-- 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-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@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.