I am trying to use Rails and the Action mailer to create a simple
contact
form on a website. I am using a table-less model to validate the form
contents, then trying to use the Action Mailer chapter of the “Agile Web
Development
with Rails” book as a pattern to develop the send e-mail portion. I am
having trouble getting it working and was hoping someone could point me
in the
right direction. Thanks.
====================================================
- class ContactController < ApplicationController
- def send_msg
- @contact = Contact.new(params[:contact])
-
if @contact.valid?
-
contact = get_contact
-
email = ContactMailer.create_confirm(contact)
-
render(:text => "<pre>" + email.encoded + "<pre>")
-
flash[:notice] = "Message Sent"
10.# redirect_to :action => ‘index’
11. else
12. render :action => ‘index’
13. end
14. end
15.
16. def get_contact
17. @contact
18. end
19.
20. end
=========================================================
Application trace is as follows:
c:/ruby/lib/ruby/gems/1.8/gems/actionpack-1.12.1/lib/action_view/base.rb:387:i
n `find_template_extension_for’
c:/ruby/lib/ruby/gems/1.8/gems/actionpack-1.12.1/lib/action_view/base.rb:323:in
`pick_template_extension’
c:/ruby/lib/ruby/gems/1.8/gems/actionpack-1.12.1/lib/action_view/base.rb:238:in
`render_file’
c:/ruby/lib/ruby/gems/1.8/gems/actionpack-1.12.1/lib/action_view/base.rb:272:in
`render’
c:/ruby/lib/ruby/gems/1.8/gems/actionmailer-1.2.1/lib/action_mailer/base.rb:363:in
`render’
c:/ruby/lib/ruby/gems/1.8/gems/actionmailer-1.2.1/lib/action_mailer/base.rb:358:in
`render_message’
c:/ruby/lib/ruby/gems/1.8/gems/actionmailer-1.2.1/lib/action_mailer/base.rb:306:in
`create!’
c:/ruby/lib/ruby/gems/1.8/gems/actionmailer-1.2.1/lib/action_mailer/base.rb:267:in
initialize' c:/ruby/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:21:in
new’
c:/ruby/lib/ruby/gems/1.8/gems/actionmailer-1.2.1/lib/action_mailer/base.rb:226:in
method_missing' #{RAILS_ROOT}/app/controllers/contact_controller.rb:7:in
send_msg’
-e:4