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:inmethod_missing’
/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
/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:inrequire’
from script/rails:6:in `’
My application suddenly started to give this message.
NoMethodError: private method `new’ called for Post.class
my post class has:
class Post < ActiveRecord::Base
The 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?
It is a Model class and a Mailer class.
But when I created my Post Mailer class I put the same name (I
forgot to add _mailer suffix)
My Model class = post.rb
My Mailer class = post.rb
That’s why this weird error was thrown. Mailer class in fact doesn’t
constructor(am I right?)
now everything is ok…
thx for your reply