我有以下型号:Rails的未定义的方法“模型名称”
class Contact
attr_accessor :name, :emails, :message
def initialize(attrs = {})
attrs.each do |k, v|
self.send "#{k}=", v
end
end
def persisted?
false
end
end
我打电话给一个接触的形式在我看来,像这样:
<div class="email_form">
<%= render 'form' %>
</div>
这里是控制器:
class ShareController < ApplicationController
layout "marketing_2013"
respond_to :html, :js
def index
@contact = Contact.new
end
end
这里是表格:
<%= form_for(@contact) do |f| %>
<%= f.label :name, "Your Name" %>
<%= f.text_field :name %>
<%= f.label :text, "Send to (separate emails with a comma)" %>
<%= f.text_field :emails %>
<%= f.label :message, "Email Text" %>
<%= f.text_area :message %>
<%= f.submit %>
<% end %>
出于某种原因,我不断收到此错误: undefined method model_name for Contact:Class
任何原因,我有什么目前是行不通的?
这已经在http://stackoverflow.com/questions/10823736/undefined-method-model-name-for-projectclass – 2013-02-13 19:50:38