Created
July 14, 2013 13:31
-
-
Save mwlang/5994288 to your computer and use it in GitHub Desktop.
Extract of an Attorney model (basically a Person)
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| class Attorney < ActiveRecord::Base | |
| # Added :uniq qualifier, not without some strife. First, in the Agile 1.2 dev book, | |
| # they incorrectly called the parameter ":unique". Then, when you get a .count | |
| # on this association (attorney.community_organizations.count), it returns the non- | |
| # unique count. So, instead, to receive an accurate count that respects the :uniq | |
| # parameter, use .size, so attorney.community_organizations.size. | |
| has_many :community_organizations, | |
| :through => :affiliations, | |
| :conditions => %{community_organization_type_id != #{CommunityOrganizationType::PROFESSIONAL_TYPE_ID}}, | |
| :order => 'name', | |
| :uniq => true | |
| has_many :professional_organizations, | |
| :through => :affiliations, | |
| :source => :community_organization, | |
| :conditions => %{community_organization_type_id = #{CommunityOrganizationType::PROFESSIONAL_TYPE_ID}}, | |
| :order => 'name', | |
| :uniq => true | |
| end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment