I am creating a form which allows a User to send another User an email without actually seeing their email address.
I am using this gem: https://github.com/plataformatec/mail_form to handle this.
Currently I am very close to getting things working. I have my app emailing the correct person and giving the correct reply information. However, I cannot get the message body to appear.
My view form. (emails/new.html.erb)
<h1>Mail#new</h1>
<p>Find me in app/views/mail/new.html.erb</p>
<%= form_for @email do |f| %>
<%= f.label :message, 'Message:' %>
<%= f.text_area :message %>
<%= f.submit "Send Message" %>
<% end %>
my controller (emails_controller.rb)
class EmailsController < ApplicationController
def new @email = Email.new flash[:userid] = params[:id]
end
def create
@touser = User.find(flash[:userid])
@fromuser = User.find(current_user.id.to_i)
@email = Email.new(:name => @fromuser.name, :email => @fromuser.email, :message => params[:message], :to => @touser.email)
if @email.deliver
flash.now[:notice] = 'Thank you for your message!'
else
render :new
end
end
end
So using params[:message] does not work. How Can I access the :message data which I collect with my view?