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

  • SEARCH
  • Home
  • 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 9170887
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 17, 20262026-06-17T16:05:20+00:00 2026-06-17T16:05:20+00:00

I am using the gem ‘foreigner’ and setup comment for my app and everything

  • 0

I am using the gem ‘foreigner’ and setup comment for my app and everything works. However, I would also like to notify my users whenever a comment is created. I’ve got two users, customers and developers. Customers can post comments and Developers can post comments.

How would I setup my comments_controller.rb file to figure out if its a customer or developer posting the comment and then send email with the right template.

So far I’ve tried the following with no work;

  def create
    @comment = Comment.new(params[:comment])

    respond_to do |format|
      if @comment.save
        if current_user.is_developer?
           Notifier.developer_notify(@developer).deliver
        elsif current_user.is_customer?
           Notifier.customer_notify(@customer).deliver
        end
        format.html { redirect_to :back, notice: 'Comment was successfully created.' }
        # format.json { render json: @comment, status: :created, location: @comment }
      else
        format.html { render action: "new" }
        # format.json { render json: @comment.errors, status: :unprocessable_entity }
      end
    end
  end

“developer_notify” and “customer_notify” being the class defined in my Notifier mailer.

My “Notifier” mailer looks like this so far;

  def developer_notify(joblisting)
    @joblisting = joblisting
    mail(:to => @joblisting.current_user.email, :subject => "There's a new comment.")
  end

@Joblisting is the job that is referenced to as each Joblisting has its own comments from customers and developers.

Doing the above, gives me an error – undefined method 'current_user' for nil:NilClass

So I’m guessing it’s not finding the Joblisting ID nor is it finding the customers email address, then if the customer posted a comment for that same job, it would send email to the developer with notification of a new comment posted.

Any suggestions?

  • 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-17T16:05:21+00:00Added an answer on June 17, 2026 at 4:05 pm

    you have passing joblisting from your controller:

    def create
     @comment = Comment.new(params[:comment])
     #you have define here joblisting for example:
      joblisting = JobListing.first #adapt the query to your needs
     respond_to do |format|
      if @comment.save
        if current_user.is_developer?
           #here add joblisting as argument after @developer
           Notifier.developer_notify(@developer, joblisting).deliver
        elsif current_user.is_customer?
           #here add joblisting as argument after @developer
           Notifier.customer_notify(@customerm, joblisting).deliver
        end
        format.html { redirect_to :back, notice: 'Comment was successfully created.' }
        # format.json { render json: @comment, status: :created, location: @comment }
      else
        format.html { render action: "new" }
        # format.json { render json: @comment.errors, status: :unprocessable_entity }
      end
     end
    end
    

    on notifier mailer

    def developer_notify(@developer, joblisting)
        @joblisting = joblisting
        mail(:to => @joblisting.current_user.email, :subject => "There's a new comment.")
      end
    

    Regards!

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

Sidebar

Related Questions

When I download something using gem I'd like to be able to just download
I am using the gem Paperclip and now I wanted to deploy my app
I have a rails app. I'm using gem:paperclip to upload photos to my server.
I'm using this gem for Facebook authentication in my Rails app. I'm having some
Using the Gem libxml-ruby, when we parse XML like so: document = LibXML::XML::Parser.string( xmlData
Want to update page after jeditable (using gem on_the_spot) has been updated. Below works
I'm using gem rapns (https://github.com/ileitch/rapns) on my rails app. According to rapns doc, I
Using gem 'bootstrap-generators', '~> 2.0' gem 'simple_form', '~> 2.0' Bootstrap style is non-existant in
I'm using gem ckeditor, 3.7.1 in my rais project. When I'm trying to upload
I'm using gem bundler (v.0.9.6) and Rails 2.3.5, rubygems 1.3.6 and ruby 1.8.7 (On

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.