我正在做一个身份验证应用程序。我有这个代码
class UsersController < ApplicationController
def new
@user = User.new
@title = "User Sign Up"
end
def create
@user = User.new(params[:user])
sign_in_check @user
if @user.save
#flash[:status] = true
#flash[:alert] = "You have successfully signed up!!"
#sign_in_check @user
redirect_to root_path, :flash => { :success => "Welcome to the Bakeshop"}
else
@title = "User Sign Up"
render 'new'
end
end
end
这是一个简单的注册代码,每当我尝试注册时,rails 都会返回错误:
undefined method `sign_in_check' for #<UsersController:0x68c0a90>
但我sign_in_check
在我的定义了一个方法Users_helper.rb
:
module UsersHelper
def sign_in_check(user)
#some stuff to enable session
end
end
有谁知道为什么会这样,以及如何解决?