ruby - Rails getting form value to create method -
i creating form allows user send user email without seeing email address.
i using gem: https://github.com/plataformatec/mail_form handle this.
currently close getting things working. have app emailing correct person , giving correct reply information. however, cannot message body 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 |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 message!' else render :new end end end
so using params[:message] not work. how can access :message data collect view?
if using form_for @email, message in params[:email][:message]
Comments
Post a Comment