Advertisement
Guest User

Untitled

a guest
Feb 5th, 2016
63
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Rails 0.37 KB | None | 0 0
  1. class Subject < ActiveRecord::Base
  2.     has_one :page
  3.     scope :newest_first , lambda {order("subjects.created_at DESC")}
  4.     scope :search, lambda{|query|
  5.      where(["name LIKE?","%#{query}%"])
  6.  
  7.       }
  8.       scope :visible ,lambda{  where(visible: true)  }
  9.       scope :invisible, lambda{  where(visible: false) }
  10.       scope :sorted ,lambda{ where ("subjects.position ASC")}
  11. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement