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

Popular posts from this blog

how to proxy from https to http with lighttpd -

android - Automated my builds -

python - Flask migration error -