Rails: Why is with_exclusive_scope protected? Any good practice on how to use it?
ruby-on-rails, scope
Solution
FYI for anyone looking for the Rails3 way of doing this, you can use the `unscoped` method:
Ticket.unscoped.all
Problem
Given a model with default_scope to filter all outdated entries: ``` # == Schema Information # # id :integer(4) not null, primary key # user_id :integer(4) not null, primary key # end_date :datetime class Ticket < ActiveRecord::Base belongs_to :user default_scope :conditions => "tickets.end_date > NOW()" end ``` Now I want to get any ticket. In this case with_exclusive_scope is the way to go, but is this method protected? Only this works: ``` Ticket.send(:with_exclusive_scope) { find(:all) } ``` Kind of a hack, isn't? So what's the right way to use? Especially when dealing with associations, it's getting even worse (given a user has many tickets): ``` Ticket.send(:with_exclusive_scope) { user.tickets.find(:all) } ``` That's so ugly!!! - can't be the rails-way!?