Hi guys, My application suddenly started to give this message. NoMethodError: private method `new'' called for Post.class my post class has: class Post < ActiveRecord::Base belongs_to :user ... end How could I fix this problem? I''m using rails 3.1.3 even if I tried to write Post.new in console this problem still happens. The funniest thing is because this error only occurs on Post class... ;/ Thx -- Bruno Meira -- 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-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
That''s the exception Rails console gave me: 1.9.2p290 :035 > post = Post.new NoMethodError: private method `new'' called for Post:Class from /home/bruno/.rvm/gems/ruby-1.9.2-p290/gems/actionmailer-3.1.3/lib/action_mailer/base.rb:455:in `method_missing'' from (irb):35 from /home/bruno/.rvm/gems/ruby-1.9.2-p290/gems/railties-3.1.3/lib/rails/commands/console.rb:45:in `start'' from /home/bruno/.rvm/gems/ruby-1.9.2-p290/gems/railties-3.1.3/lib/rails/commands/console.rb:8:in ` start'' from /home/bruno/.rvm/gems/ruby-1.9.2-p290/gems/railties-3.1.3/lib/rails/commands.rb:40:in `<top (r equired)>'' from script/rails:6:in `require'' from script/rails:6:in `<main>'' -- 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-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
On Thu, Feb 23, 2012 at 17:41, Bruno Meira <goesmeira-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> My application suddenly started to give this message. > NoMethodError: private method `new'' called for Post.class > > my post class has: > class Post < ActiveRecord::Base > belongs_to :user > ... > endThe problem is probably somewhere in the "..." part! Sounds to me like you decided to add a private method, above initialize, and forgot to go back to public. That''s why I usually leave the private stuff for last. (That, and the public stuff is more important when someone''s reading the code.) Or are there no private items in there? Are you *sure*? Use your text editor to search for the word private. Then do protected too, just in case. Is there some chance something is monkeypatching your Post class and replacing "new" with a private version? -Dave -- Dave Aronson: Available Cleared Ruby on Rails Freelancer (NoVa/DC/Remote) -- see www.DaveAronson.com, and blogs at www.Codosaur.us, www.Dare2XL.com, www.RecruitingRants.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-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe@googlegroups.com. For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
There isn''t any private or protected modifier in my class. How can I know if something is monkeypatching my class? thx for reply :D -- 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-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
I find the bug!! :D This bug happens because I forgot to Add _mailer suffix to my post mailer class ... -- 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-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
was that Post actually actionmailer class? saw ur exception coming from action mailer ? i cannot check now, only hv my mobile with me. On Feb 24, 2012 6:59 PM, "Bruno Meira" <goesmeira-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> There isn''t any private or protected modifier in my class. How can I know > if something is monkeypatching my class? > thx for reply :D > > -- > 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-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org > To unsubscribe from this group, send email to > rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org > For more options, visit this group at > http://groups.google.com/group/rubyonrails-talk?hl=en. >-- 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-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
It is a Model class and a Mailer class. But when I created my Post Mailer class I put the same name (I completely forgot to add _mailer suffix) :P My Model class = post.rb My Mailer class = post.rb That''s why this weird error was thrown. Mailer class in fact doesn''t have constructor(am I right?) now everything is ok.. thx for your reply :D -- 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-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.