named_scopeã¯å¼æ°ãåããã¨ããäºã§ãã ååã¯Aã¯ã©ã¹çã®æ¬ãæ¹ã§ããããå¼æ°ãåã£ã¦klass('A')ã®æ§ãªäºãåºæ¥ã¾ãã class Member < ActiveRecord::Base named_scope :klass, lambda {|klass| { :conditions => ['klass = ?', klass]} } end ä¸ã®æ§ã«ä½¿ãã¾ãã Member.klass 'A' # =>SELECT * FROM "members" WHERE (klass = 'A') Member.klass 'B' # =>SELECT * FROM "members" WHERE (klass = 'B') Member.klass 'C' # =>SELECT * FROM "members" WHERE (klass = 'C') # ããã¯å°ã Me
{{#tags}}- {{label}}
{{/tags}}