0

I have in the footer contact form - in the app is the whole contact scaffold. How to make this form working? So far, I am trying to do it this way - in the footer I render the form action:

= render 'contact_messages/new'

and in the ApplicationController I set up the before_filter:

  before_filter :model_for_contact
  def model_for_contact_messages
    @contact_message = ContactMessage.new
  end

But when I open the app, I am getting this error message in browser:

private method `new' called for ContactMessage:Class

How to solve this thing?

Thank you in advance

EDIT - contact_message.rb

class ContactMessage < ActiveRecord::Base
  attr_accessible :body, :email, :name, :subject
end
user984621
  • 46,344
  • 73
  • 224
  • 412

2 Answers2

1

A quick Google search found me these:

https://www.ruby-forum.com/topic/3716180#1048623

and

https://stackoverflow.com/a/11388748/832759

So perhaps you also have a mailer class with the name ContactMessage?

Community
  • 1
  • 1
j03w
  • 3,679
  • 1
  • 21
  • 15
-1

I checked this question,

Ruby Class#new - Why is `new` a private method?

From the above link and a little bit of google I did,

I found that, this link's ContactMessage class in the ActiveModel::Conversion, may have contradicted with your definition.

Community
  • 1
  • 1
beck03076
  • 3,268
  • 2
  • 27
  • 37
  • No `ContactMessage` in there is just an example code. And that is the only place this constant exist for the entire codebase https://github.com/rails/rails/search?q=ContactMessage&ref=cmdform – j03w Aug 12 '13 at 12:12