Missing something about these form parameters


#1

If I have the following form:

Send Email

<% form_remote_tag :update => 'dud', :url => {:controller => 'emailer', :action => 'sendmail'} do %>

Subject: <%= text_field 'email', 'subject' %>

Recipient: <%= text_field 'email', 'recipient' %>

Message
<%= text_area 'email', 'message' %>

<%= 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: removed_email_address@domain.invalid
Message: This is just a test!

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

messageThis is just a test!removed_email_address@domain.invalid

No wonder I cannot get the mail to send – why is it prefixing the
variables with the names of the variables themselves? -Janna B


#2

On Jun 6, 7:02 pm, JannaB removed_email_address@domain.invalid wrote:

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

messageThis is just a test!removed_email_address@domain.invalid

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