Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8919101
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 15, 20262026-06-15T05:55:51+00:00 2026-06-15T05:55:51+00:00

I have this in the Model: after_create do |comment| CommentMailer.comment_email(self).deliver end This in CommentMailer:

  • 0

I have this in the Model:

  after_create do |comment|
   CommentMailer.comment_email(self).deliver
  end

This in CommentMailer:

  class CommentMailer < ActionMailer::Base
  helper ActionView::Helpers::UrlHelper
  include CommentHelper
  helper :comment
 def comment_email(user, comment, commentable)
   mail(to: user.email,
        subject: "You have left a comment",
        from: "comments@lumeo.com",
        bcc: "brian@lumeo.com")
 end
end

And this in CommentHelper:

module CommentHelper
  def find_commentable
    @comment = Comment.find(params[:comment])
    params.each do |name, value|
      if name =~ /(.+)_id$/
        return $1.classify.constantize.find(value)
      end
    end
    nil
  end
end

I’m getting this error:

Started POST "/requests/6/comments" for 127.0.0.1 at 2012-11-30 17:28:55 -0800
Processing by CommentsController#create as HTML
  Parameters: {"utf8"=>"✓", "authenticity_token"=>"R62NH5/EE34FPapEqy7mfpa0wKz18GtSdhH8MGYq2Ec=", "comment"=>{"content"=>"post", "show"=>"true"}, "commit"=>"Create Comment", "request_id"=>"6"}
  User Load (0.3ms)  SELECT "users".* FROM "users" WHERE "users"."id" = 2 ORDER BY users.created_at DESC LIMIT 1
  Request Load (0.3ms)  SELECT "requests".* FROM "requests" WHERE "requests"."id" = $1 LIMIT 1  [["id", "6"]]
  CACHE (0.0ms)  SELECT "requests".* FROM "requests" WHERE "requests"."id" = $1 LIMIT 1  [["id", "6"]]
   (0.1ms)  BEGIN
  SQL (0.4ms)  INSERT INTO "comments" ("commentable_id", "commentable_type", "content", "created_at", "show", "updated_at", "user_id") VALUES ($1, $2, $3, $4, $5, $6, $7) RETURNING "id"  [["commentable_id", 6], ["commentable_type", "Request"], ["content", "post"], ["created_at", Sat, 01 Dec 2012 01:28:55 UTC +00:00], ["show", true], ["updated_at", Sat, 01 Dec 2012 01:28:55 UTC +00:00], ["user_id", 2]]
   (0.2ms)  ROLLBACK
Completed 500 Internal Server Error in 136ms

ArgumentError (wrong number of arguments (1 for 3)):
  app/mailers/comment_mailer.rb:5:in `comment_email'
  app/models/comment.rb:27:in `block in <class:Comment>'
  app/controllers/comments_controller.rb:22:in `create'
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-15T05:55:53+00:00Added an answer on June 15, 2026 at 5:55 am

    Looks like simple typos.

    Line 7, as noted in the exception:

    commentable = @comment.commentable
    

    So, the issues:

    • You’re calling @comment.commentabe, but @comment is nil
    • Hence the error: undefined method 'commentable' for nil:NilClass
    • @comment is nil in your mailer method because you’re passing it in as comment NOT @comment, yet you’re trying to reference it as @comment.

    Also, why are you passing in commentable as a parameter, but on line 7 you’re setting commentable again – this is redundant? Just use the already available commentable variable that you’re passing in as a param. In fact, you seem to be doing this with several variables, yet I can’t tell (because you don’t show the mailer template) whether or not you’re actually using them.

    It could be that you could use something simpler like:

    So, this should (probably) work:

    def comment_email(user, comment, commentable)
      mail(to: user.email,
           subject: "You have left a comment",
           from: "comments@lumeo.com",
           bcc: "brian@lumeo.com")
    end
    

    If you post your mail template (so I can see what the body of the email looks like) I can help you get the variables into the template.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

For example i have this model: class Product < ActiveRecord::Base attr_accessible :name, :order end
I have this Task model: class Task < ActiveRecord::Base acts_as_tree :order => 'sort_order' end
I have this Project model: class Project < ActiveRecord::Base validates :status, :inclusion => {
I have this model in django: class JournalsGeneral(models.Model): jid = models.AutoField(primary_key=True) code = models.CharField(Code,
Assume I have this model : class Task(models.Model): title = models.CharField() Now I would
I'm a django newbie. I have this model: class Item(models.Model): name = models.CharField(max_length=255) quantity
I have 3 models and polymorphic relationships. Post: #models/post.rb class Post < ActiveRecord::Base after_create
we have model helper (used by several different models) called set_guids that sets self.theguid
I have model: class Topic < ActiveRecord::Base attr_accessible :title, :description has_many :comments, :dependent =>
I have a model that gets it's view-count updated after it's viewed. This is

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.