模型:
def self.auth(username, password)
user = Users.where(:username => username).where(:password => password).first
user
end
控制器:
def auth
user = Users.auth("username", "password")
render :text => user
end
结果为零。如何解决?
感谢。
答案 0 :(得分:0)
model:
def self.auth(username, password)
user = Users.where(:username => username, :password => password).first
user
end
controller:
def auth
user = Users.auth(username, password)
render :text => user
end
答案 1 :(得分:0)
尝试使用此{/ 1}}中的model method(auth)
controller
注意:您的模型应 def auth1
user = auth(username,password)
render :text => user
end
。目前您有 singular(User)
,这与< strong> Users
,可能会在将来引发问题。