Get query result (ActiveRecord Ruby on Rails) -
model:
def self.auth(username, password) user = users.where(:username => username).where(:password => password).first user end
controller:
def auth user = users.auth("username", "password") render :text => user end
result nil. how fix it?
thanks.
try using model method(auth)
in controller
this
def auth1 user = auth(username,password) render :text => user end
note: model should singular(user)
.currently have users
,which against rails convention
, might cause problems in future.
Comments
Post a Comment