Last active
December 17, 2015 12:49
-
-
Save delba/5612818 to your computer and use it in GitHub Desktop.
Accessing ActiveRecord::Relation values
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| class Article < ActiveRecord::Base | |
| def self.no_limit | |
| all.tap do |rel| | |
| logger.info rel.values #=> {:limit => 20} | |
| rel.limit = nil | |
| end | |
| end | |
| end | |
| class ArticlesController < ApplicationController | |
| def index | |
| @articles = Article.limit(20).no_limit | |
| #=> SELECT "articles".* FROM "articles" | |
| end | |
| end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment