<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0">
  <channel>
    <title>Xenon1997 (Xenon1997)</title>
    <link>https://ruby-china.org/Xenon1997</link>
    <description/>
    <language>en-us</language>
    <item>
      <title>【求助】刚学习 Ruby，想要开发一个填写联系表格发送邮件的网页</title>
      <description>&lt;p&gt;我正在仿照以下两个方法学习制作一个网站。目的是将网页表单内容 l 发送至指定的邮箱。
&lt;a href="http://l4u.github.io/articles/create-a-rails-4-site-with-contact-us-form/#add-contact-us-form" rel="nofollow" target="_blank"&gt;http://l4u.github.io/articles/create-a-rails-4-site-with-contact-us-form/#add-contact-us-form&lt;/a&gt;
&lt;a href="https://bugjia.net/200207/67730.html" rel="nofollow" target="_blank"&gt;https://bugjia.net/200207/67730.html&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;我根据第一个链接的第五步，编写 Contact.rb，并运行服务器查看效果。此时我能够访问到我需求的表单。&lt;/p&gt;

&lt;p&gt;&lt;img src="https://l.ruby-china.com/photo/Xenon1997/33959458-7fc6-4a84-b92b-c7224b1a6a7c.png!large" title="" alt=""&gt;&lt;/p&gt;

&lt;p&gt;点击 submit 按钮后，rails 提示 NameError in ContactsController#create. 及 Uninitialized constant Mail_Form.
出错位置正是 Contact.rb 的第一行。Contact 无法继承 MailForm。 &lt;/p&gt;

&lt;p&gt;&lt;img src="https://l.ruby-china.com/photo/Xenon1997/dd5ad921-f429-47f4-8302-5d417a2ad156.png!large" title="" alt=""&gt;&lt;/p&gt;

&lt;p&gt;Stackoverflow 上的相关问题提示，是否未安装 mail_form 的 gem 包。随即使用 gem install mail_form 安装。并运行 bundle install。&lt;/p&gt;

&lt;p&gt;运行后再次启动服务器，问题没有解决。报错同上。&lt;/p&gt;

&lt;p&gt;利用 gem info 查看，mail_form 的确已经被安装了。&lt;/p&gt;

&lt;p&gt;mail_form (1.8.1)
    Authors: José Valim, Carlos Antônio
    Homepage: &lt;a href="https://github.com/plataformatec/mail_form" rel="nofollow" target="_blank"&gt;https://github.com/plataformatec/mail_form&lt;/a&gt;
    License: MIT
    Installed at: C:/Ruby26-x64/lib/ruby/gems/2.6.0&lt;/p&gt;

&lt;p&gt;利用 bundle show 指令查看是否 mail_form 被应用。提示 Could not find gem 'mail_form'.&lt;/p&gt;

&lt;p&gt;这是网页的布局设计
&lt;img src="https://l.ruby-china.com/photo/Xenon1997/e598c7cb-8d7b-480e-86e8-ba208cb1bdac.png!large" title="" alt=""&gt;&lt;/p&gt;

&lt;p&gt;这是 contacts 的 controller
&lt;img src="https://l.ruby-china.com/photo/Xenon1997/7025caf0-3793-4f5d-9332-507ee8fae293.png!large" title="" alt=""&gt;&lt;/p&gt;

&lt;p&gt;这是 contacts 的 model
&lt;img src="https://l.ruby-china.com/photo/Xenon1997/9f4449ae-ba8e-445e-ba60-6f8a4e237a80.png!large" title="" alt=""&gt;&lt;/p&gt;

&lt;p&gt;小弟才疏学浅，如有低级问题麻烦指路，感激不尽！&lt;/p&gt;</description>
      <author>Xenon1997</author>
      <pubDate>Wed, 03 Feb 2021 18:38:09 +0800</pubDate>
      <link>https://ruby-china.org/topics/40888</link>
      <guid>https://ruby-china.org/topics/40888</guid>
    </item>
  </channel>
</rss>
