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? -- Posted via http://www.ruby-forum.com/. --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
On 31 Mar 2008, at 18:08, John Smith 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> 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? > -- > Posted via http://www.ruby-forum.com/. > > >--~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
Frederick Cheung wrote:> On 31 Mar 2008, at 18:08, John Smith 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? > > FredFor 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. -- Posted via http://www.ruby-forum.com/. --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
Frederick Cheung wrote:> On 31 Mar 2008, at 18:08, John Smith 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? > > FredFor 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. -- Posted via http://www.ruby-forum.com/. --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
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? --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
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/ On 01/04/2008, at 5:51 PM, John Smith wrote:> > Frederick Cheung wrote: >> On 31 Mar 2008, at 18:08, John Smith 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. > -- > Posted via http://www.ruby-forum.com/. > > >--~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---