Skip to content
Rails Plugin: macros for adding attribute-specific scopes and orderings to ActiveRecord models
Ruby
Find file
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Failed to load latest commit information.
README
init.rb

README

Macro for generating attribute-specific selector scopes.

Similar to find_by_attribute methods, these macros provide a more flexible scoping.

  class User < ActiveRecord::Base
    named_scope_for :group_id
  end

  User.for_group_id(10).find(:all)

Also provides `order_by` scope that allows you to add order constraints to a query cleanly.

  User.order_by('created_at DESC', 'id')
Something went wrong with that request. Please try again.