All Projects → neighborland → scopy

neighborland / scopy

Licence: MIT license
Common ActiveRecord scopes as model concerns

Programming Languages

ruby
36898 projects - #4 most used programming language

Projects that are alternatives of or similar to scopy

no querying views
No more querying views in your Rails apps
Stars: ✭ 60 (+361.54%)
Mutual labels:  activerecord
active record-updated at
Touch `updated_at` by default with calls to `update_all` and `update_column(s)`
Stars: ✭ 27 (+107.69%)
Mutual labels:  activerecord
nxt state machine
A simple but powerful state machine implementation.
Stars: ✭ 14 (+7.69%)
Mutual labels:  activerecord
ebisu connection
EbisuConnection allows access to replica servers
Stars: ✭ 14 (+7.69%)
Mutual labels:  activerecord
alloy
Patchwork now rename to [alloy], alloy is a simple toolkit that makes your iOS / OS X apps development more easier.
Stars: ✭ 61 (+369.23%)
Mutual labels:  activerecord
Neo
Orm框架:基于ActiveRecord思想开发的至简化的java的Orm框架
Stars: ✭ 35 (+169.23%)
Mutual labels:  activerecord
departure
Percona's pt-online-schema-change runner for ActiveRecord migrations.
Stars: ✭ 86 (+561.54%)
Mutual labels:  activerecord
sinatra-api-server-toolbox
Sinatra API Server Toolbox (Ruby, Sinatra, ActiveRecord, postgreSQL, JSON, jQuery, AJAX)
Stars: ✭ 21 (+61.54%)
Mutual labels:  activerecord
php-orm-benchmark
The benchmark to compare performance of PHP ORM solutions.
Stars: ✭ 82 (+530.77%)
Mutual labels:  activerecord
activerecord-setops
Union, Intersect, and Difference set operations for ActiveRecord (also, SQL's UnionAll).
Stars: ✭ 21 (+61.54%)
Mutual labels:  activerecord
duck record
Used for creating virtual models like ActiveType or ModelAttribute does.
Stars: ✭ 23 (+76.92%)
Mutual labels:  activerecord
activerecord-mysql2rgeo-adapter
ActiveRecord connection adapter for gis, based on mysql and rgeo
Stars: ✭ 25 (+92.31%)
Mutual labels:  activerecord
sinatras-skeleton
Basic Sinatra Skeleton MVC CRUD App with Sprockets, Warden, ActiveRecord and PostgresQL
Stars: ✭ 13 (+0%)
Mutual labels:  activerecord
sinatra-dev-cheatsheet
A quick-and-dirty cheat sheet for creating HTML/CSS websites, and developing using Sinatra and ActiveRecord.
Stars: ✭ 44 (+238.46%)
Mutual labels:  activerecord
index shotgun
duplicate index checker 🔥 🔫 👮
Stars: ✭ 35 (+169.23%)
Mutual labels:  activerecord
activerecord-crate-adapter
Ruby on Rails ActiveRecord adapter for CrateDB
Stars: ✭ 27 (+107.69%)
Mutual labels:  activerecord
prefixed ids
Friendly Prefixed IDs for your Ruby on Rails models
Stars: ✭ 159 (+1123.08%)
Mutual labels:  activerecord
activerecord-cockroachdb-adapter
CockroachDB adapter for ActiveRecord.
Stars: ✭ 90 (+592.31%)
Mutual labels:  activerecord
microscope
🔬 Microscope adds useful scopes targeting ActiveRecord boolean, date and datetime fields.
Stars: ✭ 52 (+300%)
Mutual labels:  activerecord
paper trail-association tracking
Plugin for the PaperTrail gem to track and reify associations
Stars: ✭ 103 (+692.31%)
Mutual labels:  activerecord

Scopy

Gem Version Build Status

Scopy provides common ActiveRecord scopes as ActiveSupport model concerns.

Common scopes for the following attributes are provided:

  • created_at
  • name

Install

Add this line to your Gemfile:

gem 'scopy'

scopy works with Rails 4.0 and later.

Version 0.4 works with Rails 3.2 and later.

Usage

Include the modules you would like to use in your models:

class Dog < ActiveRecord::Base
  include Scopy::CreatedAtScopes
  include Scopy::NameScopes

The following examples assume you have a model named Dog:

Scopy::CreatedAtScopes
Dog.newest
# => most recently created dogs are first

Dog.oldest
# => most recently created dogs are last

Dog.created_since(1.month.ago)
# => only dogs created since one month ago

Dog.created_before(1.week.ago)
# => only dogs created before 1 week ago

Dog.created_between(2.weeks.ago, 1.week.ago)
# => only dogs created between 2 weeks ago & 1 week ago

Dog.created_on_day(1.day.ago)
# => dogs created yesterday

Dog.created_in_week(Date.parse("31/10/2013"))
# => dogs created in the week Sunday-Saturday around October 31, 2013

Dog.created_in_month(Time.new(2013, 1))
# => dogs created in January 2013

Dog.created_in_year(Time.new(2013))
# => dogs created in 2013
Scopy::NameScopes
Dog.name_like('snOOp')
# => dogs with names containing 'snoop' (case insensitive)

Dog.name_like('Snoop', case_sensitive: true)
# => dogs with names containing 'Snoop' (case sensitive)

Dog.name_starts_with('snOOp')
# => dogs with names starting with 'snoop' (case insensitive)

Dog.name_starts_with('Snoop', case_sensitive: true)
# => dogs with names starting with 'Snoop' (case sensitive)

Upgrading

Version 2.0
  • .excluding_ids and .excluding_id scopes were removed in version 2.0. Replace those calls with .excluding.
Version 3.0
  • Scopy::IdScopes was removed in version 3. Instead, use:
where.not(id: id)
where.not(id: ids)
where.not(id: model)
where.not(id: models)
Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].