I'm trying to get associations working, but can't seem to get it
right. I have users, who can subscribe to entities. Entities have
uploads and uploads have descriptions. I want to search
upload.description through all of a user's subscription.
Here are my models:
class User < ActiveRecord::Base
has_many :subscriptions
has_many :entity_subscriptions, :through => :subscriptions, :source
=> 'entity'
has_many :entities, :foreign_key => 'owner_id'
...
end
class Entity < ActiveRecord::Base
has_many :uploads
has_many :subscriptions
has_many :subscribers, :through => :subscriptions, :source => 'user'
...
end
class Subscription < ActiveRecord::Base
belongs_to :entity
belongs_to :user
end
class Upload < ActiveRecord::Base
belongs_to :entity
define_index do
indexes description
has :created_at
has :creator_id
has entity.subscriptions(:user_id), :as => :user_id
set_property :delta => true
end
...
end
If I add in user id, i don't get subscriptions for the user that I
want. I think I've just set it up wrong, any help is greatly
apprieciated.
Thanks,
Brian
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"Thinking Sphinx" group.
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/thinking-sphinx?hl=en
-~----------~----~----~----~------~----~------~--~---