我有以下模型:
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
为什么我目前所拥有的东西不起作用?