diff --git a/app/controllers/authors_controller.rb b/app/controllers/authors_controller.rb index aad3393..166a326 100644 --- a/app/controllers/authors_controller.rb +++ b/app/controllers/authors_controller.rb @@ -44,13 +44,7 @@ class AuthorsController < ApplicationController end def authors - @author = Author.find(params[:id]) - @authors = Array.new - @author.books.each do |b| - @authors.concat b.authors - end - @authors.uniq! - @authors.select! {|a| a != @author} + @authors = Author.find_by_sql(["select distinct a.* from books_authors_link bal1 left outer join books_authors_link bal2 on bal1.book = bal2.book left outer join authors a on a.id = bal2.author where bal1.author = ? and bal2. author != ?", params[:id], params[:id]]) respond_to do |format| format.html format.js diff --git a/app/controllers/books_controller.rb b/app/controllers/books_controller.rb index 52966cf..fee7425 100644 --- a/app/controllers/books_controller.rb +++ b/app/controllers/books_controller.rb @@ -10,7 +10,7 @@ class BooksController < ApplicationController end def index - @books = Book .where(query_filter(Book.table_name)) + @books = Book.where(query_filter(Book.table_name)) .includes(:authors, :serie) .references(:authors, :serie) .order(sort_col) .paginate(pagination)