私は次のモデルを持っています:
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
私が現在持っているものが機能しない理由は何ですか?