Browse files

Locus search by author should not be limited to one author

Closes #124.
  • Loading branch information...
1 parent f5977c6 commit 9e559ee74b2ea6450a91e4707bd2cec256d9fb7e @kohath kohath committed Jul 2, 2012
Showing with 11 additions and 3 deletions.
  1. +3 −0 CHANGELOG
  2. +3 −3 app/controllers/loci_controller.rb
  3. +5 −0 app/models/locus.rb
View
3 CHANGELOG
@@ -1,3 +1,6 @@
+==Since 0.3.3==
+* [#124] Locus search by author should not be limited to one author
+
==Since 0.3.2==
* [#69] Locus#attesting should not return duplicate loci
* [#118] Fixed crash of etymology formatter when a compound has 3+ components
View
6 app/controllers/loci_controller.rb
@@ -166,9 +166,9 @@ def unattached
end
def show_by_author
- author = Author.where(["name LIKE ?", "%" + params[:author] + "%"]).first
- if author
- author_loci = author.sources.collect(&:loci).flatten #ugh
+ authors = Author.where(["name LIKE ?", "%" + params[:author] + "%"])
+ if authors
+ author_loci = Locus.authored_by authors
@loci = author_loci.paginate(:page => params[:page], :include => {:source => {:authorship => [:author, :title]}})
end
View
5 app/models/locus.rb
@@ -29,4 +29,9 @@ def most_wanted_parse
def attests? form
(attestations.collect(&:attested_form) + Parse.forms_of(parses)).include? form
end
+
+ # Given an Author or array of Authors, return all loci authored by them.
+ def self.authored_by author_array
+ Locus.joins( :source => :authorship ).where( :authorships => { :author_id => author_array }).uniq
+ end
end

0 comments on commit 9e559ee

Please sign in to comment.