Forum: Ruby on Rails Missing something about these form parameters

Announcement (2017-05-07): www.ruby-forum.com is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see rubyonrails.org/community and ruby-lang.org/en/community for other Rails- und Ruby-related community platforms.
9f4a65c520a69cd357d830661e172272?d=identicon&s=25 JannaB (Guest)
on 2009-06-06 20:05
(Received via mailing list)
If I have the following form:

<h1>Send Email</h1>
<% form_remote_tag :update => 'dud', :url => {:controller =>
'emailer', :action => 'sendmail'} do %>
<p><label for="email_subject">Subject</label>:
<%= text_field 'email', 'subject' %></p>
<p><label for="email_recipient">Recipient</label>:
<%= text_field 'email', 'recipient' %></p>
<p><label for="email_message">Message</label><br/>
<%= text_area 'email', 'message' %></p>
<%= submit_tag "Send", {:onclick => "pageLoad()" } %>
<% end %>

Which, upon Submit, executes the following controller method:

class EmailerController < ApplicationController
  def sendmail
       recipient = params[:email]
       subject = params[:subject]
       message = params[:message]
       puts recipient
       puts subject
       puts message
       Emailer.deliver_contact(recipient, subject, message)
       return if request.xhr?
      render :nothing => true
      #render :text => 'Message sent successfully'
  end
end

And I input the following data into the form::
Subject: test
Recipient: abc@123.com
Message: This is just a test!

Why is the output I am puts'ing, look like this?

messageThis is just a test!recipientabc@123.comsubjecttest

No wonder I cannot get the mail to send -- why is it prefixing the
variables with the names of the variables themselves? -Janna B
81b61875e41eaa58887543635d556fca?d=identicon&s=25 Frederick Cheung (Guest)
on 2009-06-06 23:45
(Received via mailing list)
On Jun 6, 7:02 pm, JannaB <mistressja...@hotmail.com> wrote:

> Why is the output I am puts'ing, look like this?
>
> messageThis is just a test!recipient...@123.comsubjecttest
>
> No wonder I cannot get the mail to send -- why is it prefixing the
> variables with the names of the variables themselves? -Janna B

Look at your log file. You'll see that params[:email] is a hash (and
that's the thing you are puts-ing; the other two things are nil)

Fred
This topic is locked and can not be replied to.