404 page not found error

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

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/

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

Yuck.
rails 2 has stuff to make this much nicer, just stick

rescue_from(::ActionController::UnknownAction) {redirect_to ...}
in your application controller

Fred

Haha, you are the man Fred,
Where would the rails world be without you! :slight_smile: