When submitting using contact_us gem in rails 4 app: Error uninitialized constant ContactsController

159 views Asked by At

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 => "[email protected]",
     :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?

As requested, more info:

> bundle exec rake routes | grep contacts
      contacts GET    /contacts(.:format)           contacts#index
               POST   /contacts(.:format)           contacts#create
   new_contact GET    /contacts/new(.:format)       contacts#new
  edit_contact GET    /contacts/:id/edit(.:format)  contacts#edit
       contact GET    /contacts/:id(.:format)       contacts#show
               PATCH  /contacts/:id(.:format)       contacts#update
               PUT    /contacts/:id(.:format)       contacts#update
               DELETE /contacts/:id(.:format)       contacts#destroy
               POST   /contacts(.:format)           contact_us/contacts#create
               GET    /contacts/new(.:format)       contact_us/contacts#new
    contact_us GET    /contact-us(.:format)         contact_us/contacts#new
0

There are 0 answers