Rails 3 Action 邮件程序问题
我正在设置一个简单的反馈表单,只需要发送电子邮件而不保存到数据库。
我正在关注这个例子 http://www.railsmine.net/2010/03 /rails-3-action-mailer-example.html
如果我到达 localhost:3000/supports/new 我没有任何问题。
现在这一切都有效了,除了我需要网站主页上的反馈表。如果我使用相同的表单,我会收到以下错误。
undefined method `model_name' for NilClass:Class
这是我的表单代码。
<% form_for @support, :url => {:controller => "supports", :action => "create"}, :html => {:method => :post} do |f| %>
<%= f.label "Name" %>:<br />
<%= f.text_field :name %><br />
<%= f.label "Phone" %>:<br />
<%= f.text_field :phone %><br />
<%= f.label "Message" %><br />
<%= f.text_area :message, {:cols => 27, :rows => 6} %><br />
<%= f.submit "Submit", :value => "Send Feedback" %>
<% end %>
如何将此表单包含在我的主页中而不导致出现无方法错误?
I'm setting up a simple feedback form which just needs to send email and not save to the database.
I'm following this example
http://www.railsmine.net/2010/03/rails-3-action-mailer-example.html
If I got to localhost:3000/supports/new I have no problems.
Now this all works except that I need this feedback form on the site homepage. If I use the same form I get the following error.
undefined method `model_name' for NilClass:Class
Here's my form code.
<% form_for @support, :url => {:controller => "supports", :action => "create"}, :html => {:method => :post} do |f| %>
<%= f.label "Name" %>:<br />
<%= f.text_field :name %><br />
<%= f.label "Phone" %>:<br />
<%= f.text_field :phone %><br />
<%= f.label "Message" %><br />
<%= f.text_area :message, {:cols => 27, :rows => 6} %><br />
<%= f.submit "Submit", :value => "Send Feedback" %>
<% end %>
How can I include this form in my homepage without causing the no method error?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
@JCorcuera 不,我没有在家庭控制器操作中设置 @support 变量来解决问题。感谢您的帮助。
@JCorcuera No I wasn't setting the @support variable inside your home controller action which resolves the issue. Thanks for your help.