0

I want my app to redirect to my home page ie posts#index. It is a rails2 app which I am trying to migrate to rails 3.

def rescue_action_in_public(exception)
  flash[:notice] = "There was an error. Please try again." #  #{exception}
  redirect_to :controller => :posts, :action => :index
end

This method I presume does this task. How ever, It won't work in rails 3 and I see the 'Sorry something went wrong!' page

How can I get this functionality working in rails 3? If any more info is, needed I am willing to paste here.

2 Answers2

0

in rails 3 try this

def rescue_action_in_public(exception)
        status = status_code(exception)
        locale_path = "#{public_path}/#{status}.#{I18n.locale}.html" if I18n.locale
        path = "#{public_path}/#{status}.html"

        if locale_path && File.exist?(locale_path)
          render(status, File.read(locale_path))
        elsif File.exist?(path)
          render(status, File.read(path))
        else
          render(status, '')
        end
      end

from apidock

Navin
  • 543
  • 8
  • 27
0

You can right this way!

def rescue_action_in_public(exception)
  flash[:notice] = "There was an error. Please try again." #  #{exception}
  redirect_to posts_path
end
Rajdeep Singh
  • 17,621
  • 6
  • 53
  • 78