电子邮件地址注册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 endAnd my model
class Signup < ActiveRecord::Base validates :email, :presence => true end Signup.saveHere 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 endModel name is Signup instead of Signups
class SignupsController < ApplicationController def create Signup.create(email: params[:email]) end end更多推荐
发布评论