Skip to content

Commit

Permalink
Merge pull request #210 from projecthydra/fix_authority_deprecation
Browse files Browse the repository at this point in the history
Fix authorities deprecations
  • Loading branch information
jeremyf committed Sep 25, 2013
2 parents bb693e2 + b84978a commit 8c2b9c7
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 2 deletions.
6 changes: 5 additions & 1 deletion sufia-models/app/models/domain_term.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,9 @@ class DomainTerm < ActiveRecord::Base
deprecated_attr_accessible :model, :term

# TODO we should add an index on this join table and remove the uniq query
has_and_belongs_to_many :local_authorities, :uniq=> true
if Rails::VERSION::MAJOR > 3
has_and_belongs_to_many :local_authorities, -> {uniq}
else
has_and_belongs_to_many :local_authorities, :uniq=> true
end
end
2 changes: 1 addition & 1 deletion sufia-models/app/models/local_authority.rb
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ def self.register_vocabulary(model, term, name)
authority = self.find_by_name(name)
return if authority.blank?
model = model.to_s.sub(/RdfDatastream$/, '').underscore.pluralize
domain_term = DomainTerm.find_or_create_by_model_and_term(:model => model, :term => term)
domain_term = DomainTerm.find_or_create_by(model: model, term: term)
return if domain_term.local_authorities.include? authority
domain_term.local_authorities << authority
end
Expand Down

0 comments on commit 8c2b9c7

Please sign in to comment.