Ruby on Rails
Wednesday, December 29, 2010
What you need to do is create an additional :through relation, so that
User has_many :tasks, :through => :tabs . You may have to use the
nested_has_many_through plugin.
Marnen, thanks for pointing me in the right direction. Still, I did not suceed. The plugin you mentioned is outdated (not working with Rails3). Direct usage
class User < ActiveRecord::Base
has_many :sharedtabs, :dependent => :destroy
has_many :tabs, :through => :sharedtabs, :dependent => :destroy
has_many :tasks, :through => :tabs
end
results in:
"SQLite3::SQLException: no such column: tabs.user_id: SELECT "tasks".* FROM "tasks" INNER JOIN "tabs" ON "tasks".tab_id = "tabs".id WHERE (("tabs".user_id = 1))"
Anyway, there is a lighthouse ticket on that: https://rails.lighthouseapp.com/projects/8994/tickets/1152-support-for-nested-has_many-through-associations
(and so this might be available in Rails in future).
Still my question remains what to do in Rails 3.0.3?
--
You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group.
To post to this group, send email to rubyonrails-talk@googlegroups.com.
To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment