Skip to content

Instantly share code, notes, and snippets.

@delba
Last active December 17, 2015 12:49
Show Gist options
  • Select an option

  • Save delba/5612818 to your computer and use it in GitHub Desktop.

Select an option

Save delba/5612818 to your computer and use it in GitHub Desktop.
Accessing ActiveRecord::Relation values
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