电子邮件地址注册rails错误中的文本输入框(Email address sign up text entry box in rails error)

编程入门 行业动态 更新时间:2024-10-27 19:28:44
电子邮件地址注册rails错误中的文本输入框(Email address sign up text entry box in rails error)

首先,这是一个新秀问题。 我是初学者。 我想尝试简单的通讯注册。 除了之后弹出一个表示谢谢注册等内容的东西。

我从日志中收到此错误:

Started POST "/signups" for 127.0.0.1 at 2015-11-01 02:29:27 -0200 ActiveRecord::SchemaMigration Load (2.0ms) SELECT "schema_migrations".* FROM "schema_migrations" Processing by SignupsController#create as HTML Parameters: {"email"=>"akjbfkjsbdfkja@gmail.com"} Completed 500 Internal Server Error in 16ms (ActiveRecord: 0.0ms) NameError (uninitialized constant SignupsController::Signups): app/controllers/signups_controller.rb:3:in `create'

这是我的控制器:

class SignupsController < ApplicationController def create Signups.create! :email => params[:email] end end

而我的模特

class Signup < ActiveRecord::Base validates :email, :presence => true end Signup.save

这是我的html表格

<form id="register-newsletter" method="POST" action= "/signups"> <input type="text" name="email" required="" placeholder="Enter your email address"> <input type="submit" class="btn btn-custom-3" value="SIGN UP"> </form>

谢谢!!

Firstly, this is a rookie question. I am a beginner. I am trying to just have a simple newsletter sign up. As well as having a pop up afterwards that says something along the lines of Thanks for signing up etc..

I am getting this error from my logs:

Started POST "/signups" for 127.0.0.1 at 2015-11-01 02:29:27 -0200 ActiveRecord::SchemaMigration Load (2.0ms) SELECT "schema_migrations".* FROM "schema_migrations" Processing by SignupsController#create as HTML Parameters: {"email"=>"akjbfkjsbdfkja@gmail.com"} Completed 500 Internal Server Error in 16ms (ActiveRecord: 0.0ms) NameError (uninitialized constant SignupsController::Signups): app/controllers/signups_controller.rb:3:in `create'

Here is my controller:

class SignupsController < ApplicationController def create Signups.create! :email => params[:email] end end

And my model

class Signup < ActiveRecord::Base validates :email, :presence => true end Signup.save

Here is my html Form

<form id="register-newsletter" method="POST" action= "/signups"> <input type="text" name="email" required="" placeholder="Enter your email address"> <input type="submit" class="btn btn-custom-3" value="SIGN UP"> </form>

thanks!!

最满意答案

模型名称是Signup而不是Signups

class SignupsController < ApplicationController def create Signup.create(email: params[:email]) end end

Model name is Signup instead of Signups

class SignupsController < ApplicationController def create Signup.create(email: params[:email]) end end

更多推荐

本文发布于:2023-08-07 22:43:00,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1466043.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:输入框   电子邮件地址   文本   错误   rails

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!