Exception in Rails

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?

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 Cheung wrote:

Frederick Cheung wrote:

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?

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/