Project

unwhere

0.0
No release in over 3 years
Low commit activity in last 3 years
Remove where conditions from your AR relations
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
 Dependencies

Development

>= 0

Runtime

>= 0
 Project Readme

Unwhere

Clear all where conditions from AR relation. Could be useful if you are doing filtering and you need to use original scope.

Usage

Samples of usage:

User.where(first_name: 'John').order(:id).unwhere 
#  => User.order(:id)


User.where(first_name: 'John').order(:id).unwhere.where(first_name: 'Bob') 
#  => User.order(:id).where(first_name: 'Bob')

# for example we have scope:
# scope :admins, -> { where(role: 'admin') } 
User.admins.order(:id).unwhere
#  => User.order(:id)

It works with AR relations, scopes, etc, it's just removes where conditions. It returns relation too and you can add new where relations after it.

Installation

Add this line to your application's Gemfile:

gem 'unwhere'

And then execute:

$ bundle

Contributing

You are welcome to contribute.

License

The gem is available as open source under the terms of the MIT License.