我有以下型號: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