Pascal Friederich
2008-Jul-15 23:06 UTC
Condition on join table on a has_many :through isn''t created
Hi, i have a Permissions table with rank_id:integer, group_id:integer and a key:string a group model and a rank model. The group has_many "virtual permissions" through the join table. Each permission type is identified by the key in the permissions table with a :condition on the has_many association. But when i add a association through the has_many association it doesn''t create the permissions entry with the right key. It just puts NULL into the permissions.key field. This is my code (the important parts of the models) with a example which operation fails. http://pastie.org/234328 any ideas? --~--~---------~--~----~------------~-------~--~----~ 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-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
Pascal Friederich
2008-Jul-16 12:51 UTC
Re: Condition on join table on a has_many :through isn''t created
i wonder if this is a bug or a feature. does anyone know if this behaviour is wanted? ActiveRecord:Associations has_many tells me: :conditions - Specify the conditions that the associated object must meet in order to be included as a WHERE SQL fragment, such as authorized = 1. ** Record creations from the association are scoped if a hash is used. has_many :posts, :conditions => {:published => true} will create published posts with @blog.posts.create or @blog.posts.build. ** this only works for the joined table not for the join table? --~--~---------~--~----~------------~-------~--~----~ 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-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---