Using lambda with named scopes in Rails 3
You can define an ActiveRelation named scope inside your model Address, for example, like so:
class Address < ActiveRecord::Base scope :search, lambda {|query| where(["name LIKE ?", "%#{query}%"])} endUsing lambda with named scopes in Rails 3,
2 Comments to “Using lambda with named scopes in Rails 3”