我有用户提交电子邮件的表单,它在视图中:views/about/home.html.haml
表格如下所示:
= form_for @waitinglist do |f|
= f.email_field :email, placeholder: "Enter your email", autofocus: :true
= button_tag class: "btn btn-large btn-block btn-primary sigin-button" do
%p Put me on the waiting list
控制器如下所示:
class WaitinglistsController < ApplicationController
def create
@waitinglist = Waitinglist.new(params[:waitinglist])
if @waitinglist.save
redirect_to root_path
else
render action: :new
end
end
def new
@waitinglist = Waitinglist.new
end
end
该模型如下所示:
class Waitinglist < ActiveRecord::Base
attr_accessible :email
validates :email, presence: true
end
但我收到此错误:
undefined method `model_name' for NilClass:Class
怎么了?