Hi Everyone, I want to redirect the user to login page, when he is trying to use access unavailable page. Usually it throws me a exception error and 404 page. But here when user got 404 error he will be redirected to login page, I modified the method perform_action under the file /vendor/rails/actionpack/lib/action_controller/base.rb as follows: def perform_action if self.class.action_methods.include?(action_name) send(action_name) default_render unless performed? elsif respond_to? :method_missing method_missing action_name default_render unless performed? elsif template_exists? && template_public? default_render else #the coding was changed for to avoid 404 errors on 06/04/08 #flash[:notice]="Seems that the page you were looking for does not exist, so you\''ve been redirected here." redirect_to :controller=>''account'', :action=>''login'' #raise UnknownAction, "No action responded to #{action_name}", caller end end Its working well shall I override this function in my application controller or in some where my app files cos its now in vendor folder, regards, veeraa -- 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 -~----------~----~----~----~------~----~------~--~---
Why do that? That''s silly! You should simply catch an exception and redirect to another page rather than do that... but better to use a before_filter. Julian. Learn Ruby on Rails! Check out the FREE VIDS (for a limited time) VIDEO #3 out NOW! http://sensei.zenunit.com/ On 08/04/2008, at 3:31 PM, Veera Sundaravel wrote:> > Hi Everyone, > > I want to redirect the user to login page, when he is trying to use > access unavailable page. Usually it throws me a exception error and > 404 > page. > > But here when user got 404 error he will be redirected to login > page, I > modified the method perform_action under the file > /vendor/rails/actionpack/lib/action_controller/base.rb > as follows: > > def perform_action > if self.class.action_methods.include?(action_name) > send(action_name) > default_render unless performed? > elsif respond_to? :method_missing > method_missing action_name > default_render unless performed? > elsif template_exists? && template_public? > default_render > else > #the coding was changed for to avoid 404 errors on 06/04/08 > #flash[:notice]="Seems that the page you were looking for does not > exist, so you\''ve been redirected here." > redirect_to :controller=>''account'', :action=>''login'' > #raise UnknownAction, "No action responded to > #{action_name}", > caller > end > end > > Its working well shall I override this function in my application > controller or in some where my app files cos its now in vendor folder, > > regards, > veeraa > -- > 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 -~----------~----~----~----~------~----~------~--~---
On 8 Apr 2008, at 06:31, Veera Sundaravel wrote:> > Hi Everyone, > > I want to redirect the user to login page, when he is trying to use > access unavailable page. Usually it throws me a exception error and > 404 > page.Yuck. rails 2 has stuff to make this much nicer, just stick rescue_from(::ActionController::UnknownAction) {redirect_to ...} in your application controller Fred> > > But here when user got 404 error he will be redirected to login > page, I > modified the method perform_action under the file > /vendor/rails/actionpack/lib/action_controller/base.rb > as follows: > > def perform_action > if self.class.action_methods.include?(action_name) > send(action_name) > default_render unless performed? > elsif respond_to? :method_missing > method_missing action_name > default_render unless performed? > elsif template_exists? && template_public? > default_render > else > #the coding was changed for to avoid 404 errors on 06/04/08 > #flash[:notice]="Seems that the page you were looking for does not > exist, so you\''ve been redirected here." > redirect_to :controller=>''account'', :action=>''login'' > #raise UnknownAction, "No action responded to > #{action_name}", > caller > end > end > > Its working well shall I override this function in my application > controller or in some where my app files cos its now in vendor folder, > > regards, > veeraa > -- > 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 -~----------~----~----~----~------~----~------~--~---
>> > > Yuck. > rails 2 has stuff to make this much nicer, just stick > > rescue_from(::ActionController::UnknownAction) {redirect_to ...} > in your application controller > > FredHaha, you are the man Fred, Where would the rails world be without you! :) --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---