zhangxue / scope-builder Goto Github PK
View Code? Open in Web Editor NEWThis project forked from ryanb/scope-builder
Build up named scopes conditionally.
License: MIT License
This project forked from ryanb/scope-builder
Build up named scopes conditionally.
License: MIT License
= Scope Builder Build up named scopes conditionally. == Install First specify it in your Rails config. config.gem 'ryanb-scope-builder', :lib => 'scope_builder', :source => 'http://gems.github.com' And then install it. rake gems:install Rails 2.1 or later required. == Usage This gem adds the scope_builder method to all Active Record models. A builder behaves exactly like any other named scope except that calling other named scopes on it will alter the builder itself rather than returning a new named scope. builder = Product.scope_builder builder.released.visible # call a couple named scopes to change builder builder.cheap if only_show_cheap_products? # build scopes conditionally The scope_builder method can also take a block which will return the builder. This is useful when you are using the builder in a model search method. # in product model def self.search(options) scope_builder do |builder| builder.released.visible builder.cheap if options[:cheap] end end The scope_builder method can also be called on an existing scope. products = Product.released.visible builder = products.scope_builder builder.cheap if only_show_cheap_products? == Development This project can be found on github at the following URL. http://github.com/ryanb/scope-builder/ If you would like to contribute to this project, please fork the repository and send me a pull request.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.