JDutil / contact_us

Gem providing simple Contact Form functionality with a Rails 3+ Engine.
http://contact-us-demo.herokuapp.com
MIT License
135 stars 57 forks source link

name and subject field #19

Closed JulienItard closed 11 years ago

JulienItard commented 11 years ago

hi,

i add on my /config/initializers/contact_us.rb file config.require_name = true config.require_subject = true as said on your description.

Then i add in my form :

%div
    = f.label :name, "Nom"
    = f.text_field :name

%div
    = f.label :subject, "Objet"
    = f.text_field :subject

And i have this error : undefined method `name'

What's wrong ?

Thx :)

JDutil commented 11 years ago

Which version are you using? Did you restart your server after updating your initializer? What does the rest of the form look like?

JulienItard commented 11 years ago

Edit : I use gem 'contact_us'

instead of gem 'contact_us', '~> 0.4.0'

now it's work. :)


I use the latest verion of your gem, ruby 1.9.3, rails 3.2.9.

I already try to restart, same problem.

My form is :

%h1 Contact

= form_for @contact, :url => contacts_path do |f| = render 'shared/errors', object: f.object

%div
    = f.label :email, "Email"
    = f.text_field :email

%div
    = f.label :name, "Nom"
    = f.text_field :name

%div
    = f.label :subject, "Objet"
    = f.text_field :subject

%div
    = f.label :message, "Message"
    = f.text_area :message

%div.no-border
    = f.submit 'Envoyer', :class => "button"
JDutil commented 11 years ago

What is the path your template is saved as? Is error undefined method name for nil? I think your @contact object may be nil depending on if your customizing the controller or using the wrong template path.

JulienItard commented 11 years ago

Oops I use gem 'contact_us'

instead of gem 'contact_us', '~> 0.4.0'

now it's work. :) sorry for the inconvenience