My app has feeds and items. Users can subscribe to feeds, which I track in
a Subscription class.
I wanted an association for all of a user's unread items:
class Subscription < ActiveRecord::Base
belongs_to :feed
belongs_to :user
has_many :unread_items, :through => :feed, :source => :items, :conditions
=> proc {
"not exists ( select * from readings where readings.item_id = items.id
AND readings.user_id = #{user_id} )"
}
...
This works fine if I reference it directly (i.e,
@user.subscriptions.first.unread_items). But if I try to eager load or join
against it:
eager load: 'self' in the conditions proc refers to the intermediate object
(here, the Feed class) which I don't think is expected. Crashes because
Feed obviously has no user_id in my app.
join: 'self' in the conditions proc refers to a JoinDependency object,
which seems totally wrong.
--
You received this message because you are subscribed to the Google Groups "Ruby
on Rails: Core" group.
To view this discussion on the web visit
https://groups.google.com/d/msg/rubyonrails-core/-/66WrX-IovzMJ.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to
[email protected].
For more options, visit this group at
http://groups.google.com/group/rubyonrails-core?hl=en.