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 4000552
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 20, 20262026-05-20T07:47:44+00:00 2026-05-20T07:47:44+00:00

I have a fairly simple Rails application that allows users to manage their clients

  • 0

I have a fairly simple Rails application that allows users to manage their clients and create a case for each client. When a case is created the details are sent to two email addresses (different content in each email) and using a gem, sends the information to FreeagentCentral.

I have implemented delayed_job which is working well for the Freeagent API call, but I think there is probably a better, lower overhead, method of sending the emails. It seems to take quite a while.

I currently have the following code in my Rails 2.3 application.

kases_controller.rb

# POST /kases
# POST /kases.xml
  def create
    @company = Company.find(params[:kase][:company_id])
    @kase = @company.kases.new(params[:kase])

    if @kase.save
        UserMailer.deliver_makeakase("dropbox@1223111.domain.highrisehq.com", "Highrise", @kase) if params[:sendtohighrise]
        UserMailer.deliver_makeakaseteam("surveymanager@domain.co.uk", "Highrise", @kase) if params[:notify_team_of_creation]
        @kase.delay.create_freeagent_project(current_user) if params[:send_to_freeagent]

        redirect_to(@kase)

        #flash[:notice] = 'Case was successfully created.'
        flash[:notice] = fading_flash_message("Case was successfully created.", 5)
      else
        render :new
      end        
  end

user_mailer.rb

def makeakase(email, name, kase, bccemails = [])
      recipients email
      from "info@domain.co.uk"
      subject "FW: Case creation from Survey Manager"
      bcc bccemails
      sent_on Time.now
      body :name => name, :kase => kase
  end

  def makeakaseteam(email, name, kase = [])
      recipients email
      from "info@domain.co.uk"
      subject "A new case has been created."
      sent_on Time.now
      body :name => name, :kase => kase
      content_type "text/html"
  end

I am looking for any advice on slimming down the number of emails sent, or a way of adding the emails to the delayed jobs.

I use PostmarkApp for sending the emails, which is another gem. Details of which can be found here: postmark-gem

  • 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-05-20T07:47:45+00:00Added an answer on May 20, 2026 at 7:47 am

    Not sure if this is what you want, but i would make a method that would do the sending of the emails and the creation of the freeagent, and then let it be handled by delayed_job.

    Something like

    class Kase
    
      def send_emails(current_user, send_to_highrise, notify_team, send_to_freeagent)
        UserMailer.deliver_makeakase("dropbox@1223111.domain.highrisehq.com", "Highrise", self) if send_to_highrise
        UserMailer.deliver_makeakaseteam("surveymanager@domain.co.uk", "Highrise", self) if notify_team
        self.create_freeagent_project(current_user) if send_to_freeagent
      end
    end
    

    and in your controller you would then write

    if @kase.save
      @kase.delay.send_emails(current_user, params[:sendtohighrise], 
                             params[:notify_team_of_creation], params[:send_to_freeagent])
      redirect_to @kase
      flash[:notice] = fading_flash_message("Case was successfully created.", 5)
    else
      ...
    

    or just handing down the params is maybe simpler/cleaner.

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

Sidebar

Related Questions

No related questions found

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.