sql - Perform Method on all entries on the whole Ruby class (using Rails framework) -


i trying write method selects subset of members of user class. here attempt:

 def self.stats_users(date)                                                    self.where("employee = false , last_sign_in_at >= ?", date)            end    

i tried call function in manner: user.stats_user('2011-04-14')

however, method executing sql statement:

select "users".* "users" (employee = false , last_sign_in_at >= '2011-04-14') 

when should execute:

select * "users" (employee = false , last_sign_in_at >= '2011-04-14') 

i guess real question revolves around writing methods act on members of class , relative ignorance of put these methods , how call them. appear having little trouble understanding how activerecord transforms statements raw sql.

re sql

the queries equivalent in case.

re methods collections

this scopes for:

scope :stats_users, lambda { |date|    where("employee = false , last_sign_in_at >= ?",date) }           

Comments

Popular posts from this blog

c# - how to write client side events functions for the combobox items -

exception - Python, pyPdf OCR error: pyPdf.utils.PdfReadError: EOF marker not found -