It continues with the same error. I have created with a scaffold a
posts_controller:
class PostsController < ApplicationController
rescue_from Activerecord::NoMethodError. with => :not_found
protected
def not_found
Code
end
end
But it gives me the same error when I go to some view: NoMethod error.
What’s is it wrong?
On 31 Mar 2008, at 18:08, John S. wrote:
It continues with the same error. I have created with a scaffold a
posts_controller:
class PostsController < ApplicationController
rescue_from Activerecord::NoMethodError. with => :not_found
You’ve got several typos in here. What’s actually in your posts
controller?
In addition NoMethodError sounds like a bad thing to be rescuing like
this. What’s the real problem you’re trying to solve?
Fred
Frederick C. wrote:
On 31 Mar 2008, at 18:08, John S. wrote:
It continues with the same error. I have created with a scaffold a
posts_controller:
class PostsController < ApplicationController
rescue_from Activerecord::NoMethodError. with => :not_found
You’ve got several typos in here. What’s actually in your posts
controller?
In addition NoMethodError sounds like a bad thing to be rescuing like
this. What’s the real problem you’re trying to solve?
Fred
For example, considerar I have an object named product. This product has
a price. If I destroy that product and go to a ticket index view
(showinng ID, client name and product) I get NoMethodError with
ticket.product.price. Of course, if I don’t destroy that product, I
don’t get that error.
Frederick C. wrote:
On 31 Mar 2008, at 18:08, John S. wrote:
It continues with the same error. I have created with a scaffold a
posts_controller:
class PostsController < ApplicationController
rescue_from Activerecord::NoMethodError. with => :not_found
You’ve got several typos in here. What’s actually in your posts
controller?
In addition NoMethodError sounds like a bad thing to be rescuing like
this. What’s the real problem you’re trying to solve?
Fred
For example, considerar I have an object named product. This product has
a price. If I destroy that product and go to a ticket index view
(showinng ID, client name and product) I get NoMethodError with
ticket.product.price. Of course, if I don’t destroy that product, I
don’t get that error.
Yeah I’ve often lamented the fact that we need a “halt dot-method
chain” in ruby.
Julian.
Learn about Ruby on Rails! CHECK OUT THE FREE VIDS (LIMITED TIME) NEW
VIDEO OUT 3rd APRIL
http://sensei.zenunit.com/
Oh dear god!
def show
@product = Product.find(params[:id])
rescue ActiveRecord::RecordNotFound
not_found
end
protected
def not_found
your_code_here
end
Is it really that hard?