This project is archived and is in readonly mode.
scope firings up on association
Reported by eagle.anton (at gmail) | December 24th, 2010 @ 02:27 PM
For example:
class Post < ActiveRecord
belongs_to :user
scope :published, where(:published => true)
def self.some_action
u = User.find(x)
u.posts
end
end
Post.published.some_action # => SELECT "posts".* FROM "posts" WHERE "published" = "t" AND ("user_id" = "x");
Why there are we have scope for user association ? It should be isolated, isn't it?
Comments and changes to this ticket
-
eagle.anton (at gmail) December 24th, 2010 @ 02:41 PM
- Tag changed from scope association to association, rails3, scope
-
Anil Wadghule December 24th, 2010 @ 05:56 PM
Hi Eagle.
What do you mean by not needing scope for user association. Can you please elaborate more?
-
eagle.anton (at gmail) December 27th, 2010 @ 07:50 AM
Problem was solved by AR#unscoped with block:
def self.some_action u = User.find(x) unscoped { u.posts } end
Ticket may be closed. Thank you.
-
Rohit Arondekar January 2nd, 2011 @ 01:10 AM
- State changed from new to invalid
- Importance changed from to Low
Create your profile
Help contribute to this project by taking a few moments to create your personal profile. Create your profile »
<h2 style="font-size: 14px">Tickets have moved to Github</h2>
The new ticket tracker is available at <a href="https://github.com/rails/rails/issues">https://github.com/rails/rails/issues</a>