Monday, November 21, 2011

rescue_from temporary fix for rails 3.0 and 3.1

In rails 3.0 and 3.1 rescue_from will not successfully rescue a ActionController::RoutingError (Bug Report). Based on comments in the bug report here is the solution I came up with. A way that handles this bug temporarily and once it is fixed all that needs to be cleaned up is a single line in the routes.

First set up a simple errors controller:
class ErrorsController < ApplicationController
  def missing_page
   render :status => :not_found

The view for missing_page is intended to be shown to visitors as the 404 page, it uses the application layout as set up here but you can set :layout to false or whatever other layout you might wish to use.
In the application controller add the following lines:
rescue_from ActiveRecord::RecordNotFound, :with => :missing_page
rescue_from ActionController::UnknownAction, :with => :missing_page
rescue_from ActionController::RoutingError, :with => :missing_page
The first two lines work as expected, the line with ActionController::RoutingError does not work correctly though, it will start working once the bug is fixed.

The temporary fix for routing errors not being handled properly is to add the following line as the last route in the route file.
match '*path', :to => 'errors#missing_page'

Once the bug is fixed all you need to do to clean this up is remove the line that was placed at the end of the route file.


Unknown said...

Thank you for sharing like this information. This is the most easy way of learning. This helps me to get some idea regarding this and helps me to bring a creative thought.
Java Training in Chennai

Unknown said...

Brilliant post thanks for lots of sharing really great post i am very happy to read your post e commerce web development

IICT said...

I am very much fond of your nice post..IICT is the best Java Training Institute in Chennai managed by MNC Experts.

Unknown said...

Very Much Informative and cool post.. eagerly waiting for more post..
SAP Training in Chennai | SAP Training Institutes in Chennai | Best SAP Training in Chennai

Unknown said...

Nice psot.. loved it
ETL Testing Training in Chennai | Informatica Training in Chennai

Unknown said...

Pretty article! I found some useful information in your blog, it was awesome to read, thanks for sharing this great content to my vision, keep sharing.
PMP Training | PMP Training in Chennai

Unknown said...

Thanks for sharing this informative blog. I have read your blog and I gathered some valuable information from this blog. Keep posting.
Java Training in Chennai | SAP Training in Chennai

Unknown said...

Java training center java training center in Chennai
java learning material download from java tutorial for java beginners

Selenium training center selenium testing raining center in chennai
Mettur dam updates Mettur Diary

Unknown said...

Good one, very informative.. thanks for sharing your views and ideas.. it is very useful to me.. thanks once again.

Best Java Training in chennai

Java Course in chennai

Unknown said...

nice and excellent post..

PHP Training Institute in Chennai

Kamal said...

I am perusing your post from the earliest starting point, it was so fascinating to peruse and I feel because of you for posting such a decent blog.
Education | Article Submission sites | Technology

mathimathi said...

Thank you so much for all the wonderful information about sensors! I love your work
PHP Training in Chennai |
PHP Course in Chennai |
PHP Training Institute in Chennai

mathimathi said...

Wow, what great information. I am sure the info on your blog will help others, as I am trying to do as well.
German Language Classes in Chenna |
German Classes in Chennnai |
German Courses in Chennai

pavithra dass said...

Nice blog!! I hope you will post more articles like this!!
Selenium Training in Chennai
Selenium Course in Chennai
Big Data Training in Chennai
German Language Classes in Chennai
Selenium Training in Velachery
Selenium Training in Porur
Selenium Training in Adyar

Aditi Ray said...

TreasureBox is operated by a group of young, passionate, and ambitious people that are working diligently towards the same goal - make your every dollar count, as we believe you deserve something better.
Check out the best
entertainment unit

jose said...

Really nice post. Thank you for sharing amazing information.
Java Training in Chennai/Java Training in Chennai with Placements/Java Training in Velachery/Java Training in OMR/Java Training Institute in Chennai/Java Training Center in Chennai/Java Training in Chennai fees/Best Java Training in Chennai/Best Java Training in Chennai with Placements/Best Java Training Institute in Chennai/Best Java Training Institute near me/Best Java Training in Velachery/Best Java Training in OMR/Best Java Training in India/Best Online Java Training in India/Best Java Training with Placement in Chennai

kishore said...

Great blog...! This blog contains useful information about this topic. Thank you for sharing this blog and can you do more updates & sharing like from this blog.
Excel Training in Chennai
Excel Advanced course
Pega Training in Chennai
Job Openings in Chennai
Tableau Training in Chennai
Unix Training in Chennai
Oracle Training in Chennai
Soft Skills Training in Chennai
JMeter Training in Chennai
Excel Training in OMR
Excel Training in Anna Nagar

Venkatesh CS said...

Excellent Blog. Thank you so much for sharing.
best react js training in chennai
react js training in Chennai
react js workshop in Chennai
react js courses in Chennai
react js training institute in Chennai
reactjs training Chennai
react js online training
react js online training india
react js course content
react js training courses
react js course syllabus
react js training
react js certification in chennai
best react js training

The India said...

Delhi Mathura Vrindavan Tour by Bus
Agra Mathura Tour Package by Bus
Delhi to Agra tour by Volvo bus
Online Bus Ticket Booking for Agra
Same Day Agra Tour
Same Day Agra Tour by Bus

Venkatesh CS said...

Thanks for sharing valuable information.
Digital Marketing training Course in chennai
digital marketing training institute in chennai
digital marketing training in Chennai
digital marketing course in Chennai
digital marketing course training in omr
digital marketing certification in omr
digital marketing course training in velachery
digital marketing training center in chennai
digital marketing courses with placement in chennai
digital marketing certification in chennai
digital marketing institute in Chennai
digital marketing certification course in Chennai
digital marketing course training in Chennai
Digital Marketing course in Chennai with placement
digital marketing courses in chennai

Adhuntt said...

Great blog thanks for sharing Looking for the best creative agency to fuel new brand ideas? Adhuntt Media is not just a digital marketing company in chennai. We specialize in revamping your brand identity to drive in best traffic that converts. Buckle up for a ride that is going to be filled with SEO, Social media marketing, unique Graphic & Logo design and efficient ads strike the perfect chord! Join the Adhuntt Media adventure right at Adhuntt Media
digital marketing company in chennai

Karuna said...

Nice blog thanks for sharing Out of creative ways to set up a vegetable garden? Karuna Nursery is run by the best gardeners in chennai who are ready to offer you with amazing
plant nursery in chennai

Pixies said...

Excellent blog thanks for sharing Pixies beauty Shop is the best place to buy cosmetics in Chennai. With thousands of premium imported brands to choose from, you’ll never run out of lipstick again. And don’t forget about the best offers and value they provide.
beauty Shop in Chennai

lokesh said...

This blog contains useful information. Thank you for deliverying this usfull blog..
Spoken English Classes in Bangalore
Spoken English Classes in Chennai
English Speaking Course in Bangalore
Best Spoken English Classes in Bangalore
Spoken English in Bangalore
Spoken English Classes in Marathahalli
AWS Training in Bangalore
Data Science Courses in Bangalore
DevOps Training in Bangalore
DOT NET Training in Bangalore

Indpac said...

Very useful blog thanks for sharing IndPac India the German technology Packaging and sealing machines in India is the leading manufacturer and exporter of Packing Machines in India.

James Williams said...

Great Post, I hope really gather lot of information here. thanks for sharing your idea.
React JS Online Training
React JS Online Course
React JS Online Training in chennai

Babu said...

This is such an excellent article, I am very clarified with your content.
php 7.0
digital marketing ideas
big data use cases
roles in salesforce
android interview question and answer

카지노 뉴스 정보 사이트 said...

You should always use correct punctuation in a comment.카지노사이트