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

When submitting, uninitialized constant ContactsController #54

Closed pwndude closed 9 years ago

pwndude commented 9 years ago

I've looked at several stackoverflow questions that seem similar to this one, as well as all the issues in the contact_us github repository, but the answers provided there don't solve this issue. I'll go over the code I have and hopefully I can get some help. :)

I have setup my ActionMailer, correctly to my best knowledge, using Mailgun and their own example code as follows:

Development.rb

config.action_mailer.delivery_method = :smtp  
config.action_mailer.default_charset = "utf-8"  
config.action_mailer.perform_deliveries = true  
config.action_mailer.raise_delivery_errors = true  
config.action_mailer.smtp_settings = {  
     :authentication => :plain,
     :address => "smtp.mailgun.org",
     :port => 587,
     :domain => "my-mailgun-domain.com",
     :user_name => "postmaster@my-mailgun-domain.com",
     :password => "my-password"
}

of course, I placed my own domain, username and password from Mailgun in place of the dummy attributes.

The app/mailer/contact_us/new_formtastic.html.erb was generated during 'rake exec contact_us:install' and is as follows:

<h2><%= t('.contact_us') %></h2>
 <%= semantic_form_for @contact, :url => contacts_path do |f| %>
 <%= f.input :name, :label => t('.name') if ContactUs.require_name %>
 <%= f.input :email, :label => t('.email') %>
 <%= f.input :subject, :label => t('.subject') if ContactUs.require_subject %>
 <%= f.input :message, :as => :text, :label => t('.message') %>
 <%= f.action :submit, :label => t('.submit'), :button_html => { :alt => t('.submit'), :id => 'contact_us_contact_submit', :title => t('.submit') } %>
<% end %>

I'm using Formtastic, as opposed to simple_form, and have specified so in contact_us.rb, in place of nil as is stated in the contact_us installation instructions.

I have also (I assume correctly) placed my Mailgun mailer username in the 'config.mailer_from =' and my desired target address in 'config.mailer_to =' places in contact_us.rb. (both of which are omitted due to security reasons)

The form renders properly on the page, but when submitting, I get the aforementioned error.

Is this a routing issue?? Not really sure where to begin. PLZ HALP!!!

JDutil commented 9 years ago

The controller is ContactUs::ContactsController not just ContactsController I'm not sure why your submitting to the wrong controller, but this works for me.