【发布时间】:2013-02-13 19:44:58
【问题描述】:
我有以下型号:
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
我目前所拥有的东西不起作用的任何原因?
【问题讨论】:
-
这个问题已经在stackoverflow.com/questions/10823736/…回答了
标签: ruby-on-rails-3 activemodel