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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 9, 20262026-06-09T06:22:56+00:00 2026-06-09T06:22:56+00:00

New to rails!!! How do i make my Send button call a function (sendmail)

  • 0

New to rails!!!
How do i make my “Send” button call a function (sendmail) which sends an email?
This is what I have so far….
The sendmail in events_controller does not called!
And I have an event in my model, and i am running rails 3.2.3

show.html.erb:

<p><b>Send Results</b></p>
<%= form_tag("/events", :method => "get") do %>
<p><label for="email_recipient">Email recipient</label>:
<%= text_field 'email', 'Email recipient' %></p>
<%= submit_tag "Send" %>
<% end %>

routes.rb:

resources :events do
      member do 
          get '/sendmail', :as => :sendmail
      end
  end

events_controller.rb

   def sendmail
        puts "sendmail"
        Emailer.deliver_results_email
        return if request.xhr?
        render :text => 'Message sent successfully'
  end

emailer.rb

class Emailer < ActionMailer::Base
  #default from: "from@example.com"
  def results_email
    puts "RESULTS EMAIL"
    #NEVER GETS THIS FAR.....
  end
end
  • 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-09T06:22:58+00:00Added an answer on June 9, 2026 at 6:22 am

    First things first. In your routes.rb you have put the sendmail action inside a member block. This would generate a route like this:

    /events/:id/sendmail
    

    If the sendmail action is kindda generic and don’t need to be applied on a single ‘event’, maybe you should put it on a collection block, so your route would be like this:

    /events/sendmail
    

    Second, if you run rake routes | grep sendmail in your console, you will get something like this outputed:

    sendmail_event GET /events/:id/sendmail events#sendmail
    

    What this line is saying is that you have a route configured and you have a helper route method named sendmail_event_path that you can use to facilitate the understanding of your views, etc. So in your view it would be something like this:

    <%= form_tag sendmail_event_path(@event.id) %>
      ...
    <% end %>
    

    When you click the submit button the form would be POSTED to the sendmail action of your events_controller.

    I suggest you to change your route to a collection, and change to :post, so you can use it without the event isntance.

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

Sidebar

Related Questions

I have the following setup to send email at sign up: Rails 3.0.7 ruby
I'm new to Rails and was following Ryan Bate's tutorial on how to make
I am new to Ruby on Rails and I am trying to make a
Starting a new rails project and we have a well-thought-out color palette, and want
I'm developing a new rails application which is supposed to be installed several times
I'm new to rails and I'm trying to make a help page that just
I have been using mysql in a new rails application, but now I wanted
I am building an application which will send status requests to users (via email
I'm super new to Ruby on Rails. I'm trying to make an authentication system
I've managed to make a new rails project skeleton with no problems. However, when

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.