Jump to content

The ultimate community for Ruby on Rails developers.


Photo

mail_form gem

rails mail_form ruby gem

  • Please log in to reply
7 replies to this topic

#1 conal4284

conal4284

    Passenger

  • Members
  • 7 posts

Posted 27 August 2013 - 05:50 AM

I want to create a Contact form for which I found mail_form gem in some forum. I tried to using it but didn't get it working. Following is my code snippet:

Ruby 1.8.7

Rails 2.3.15

mail_form 1.0.0

 

contact_form_controller.rb

 

require 'mail_form'

class ContactFormController < ApplicationController
  def new
    @contact_form = ContactForm.new
    respond_to
do |format|
     format.html
     format
.xml
    end
  end

  def create
    begin
      @contact_form = ContactForm.new(params[:contact_form])
      @contact_form.request = request
      if @contact_form.deliver
       flash
.now[:notice] = 'Thank you for your message!'
      else
       render :new
      end
    end
  end

end

 

contact_form.rb

 

require 'mail_form'

 

class ContactForm < MailForm

  subject "My Contact Form"
  recipients "abc@gmail.com"
  sender{|c| %{"#{c.name}" <#{c.email}>}}

end

 

new.html.erb

 

<% form_for @contact_form do |f| %>

  <%= f.error_messages %>
  <%= f.label :name %>
  <%= f.text_field :name %><br/>

  <%= f.label :email %>
  <%= f.text_field :email %><br/>

  <%= f.lable :message %>
  <%= f.text_area :message %><br/>

  <%= f.submit 'Submit' %>
<% end %>

 

 

Any suggestions would help me lot. Thanks in advance.

 



#2 Ohm

Ohm

    Guard

  • Members
  • 179 posts
  • LocationCopenhagen

Posted 27 August 2013 - 08:30 AM

Ruby 1.8.7

Rails 2.3.15

mail_form 1.0.0

 

Rails 2.3.15? Ouch.

 

mail_form is at version 1.5.0.rc in their GitHub repo https://github.com/p...form/version.rb

 

What is not working? 


Blog: http://ohm.sh | Twitter: madsohm


#3 conal4284

conal4284

    Passenger

  • Members
  • 7 posts

Posted 27 August 2013 - 09:10 AM

Rails 2.3.15? Ouch.

 

mail_form is at version 1.5.0.rc in their GitHub repo https://github.com/p...form/version.rb

 

What is not working? 

 

The form itself is not loading..

 

http://localhost:3000/contact_form/new

 

gives following error:

undefined method `contact_forms_path' for #<ActionView::Base:0xb6b359b4>



#4 Ohm

Ohm

    Guard

  • Members
  • 179 posts
  • LocationCopenhagen

Posted 27 August 2013 - 09:17 AM

What is in your routes.rb file and what does rake routes give you?


Blog: http://ohm.sh | Twitter: madsohm


#5 conal4284

conal4284

    Passenger

  • Members
  • 7 posts

Posted 27 August 2013 - 09:29 AM

What is in your routes.rb file and what does rake routes give you?

routes.rb file contains map.resources :contact_form



#6 Ohm

Ohm

    Guard

  • Members
  • 179 posts
  • LocationCopenhagen

Posted 27 August 2013 - 09:31 AM

... and what does rake routes tell you? Is there actually a path called contact_forms_path is what I'm hinting at.


Blog: http://ohm.sh | Twitter: madsohm


#7 conal4284

conal4284

    Passenger

  • Members
  • 7 posts

Posted 27 August 2013 - 09:47 AM

... and what does rake routes tell you? Is there actually a path called contact_forms_path is what I'm hinting at.

rake routes is not working

 

 

rake aborted!
ERROR: 'rake/rdoctask' is obsolete and no longer supported. Use 'rdoc/task' (available in RDoc 2.4.2+) instead. What should I do now?


#8 Bharat Soni

Bharat Soni

    Dispatcher

  • Members
  • 53 posts
  • LocationAhmedabad

Posted 16 October 2013 - 09:22 AM

 

rake routes is not working

 

 

rake aborted!
ERROR: 'rake/rdoctask' is obsolete and no longer supported. Use 'rdoc/task' (available in RDoc 2.4.2+) instead. What should I do now?

 

 

Just change in the rake file as the ERROR shows

 

require 'rdoc/task'


Fun with Ruby on Rails






Also tagged with one or more of these keywords: rails, mail_form, ruby, gem

0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users