From 46f6c5590684c3cb7449ae335fed5f397815f507 Mon Sep 17 00:00:00 2001 From: Meutel Date: Fri, 14 Aug 2015 10:10:22 +0200 Subject: [PATCH] order books in serie --- app/controllers/series_controller.rb | 4 ++-- app/models/book.rb | 1 + app/views/series/show.html.erb | 2 +- 3 files changed, 4 insertions(+), 3 deletions(-) diff --git a/app/controllers/series_controller.rb b/app/controllers/series_controller.rb index b129472..ee621fa 100644 --- a/app/controllers/series_controller.rb +++ b/app/controllers/series_controller.rb @@ -4,7 +4,7 @@ class SeriesController < ApplicationController before_action :preferences, only: :index def show - @serie = Serie.find(params[:id]) + @serie = Serie.includes(books: :authors).references(:book).find(params[:id]) @title = @serie.name end @@ -14,7 +14,7 @@ class SeriesController < ApplicationController .references(:books) .order(:sort) .paginate(pagination) - @title = "Series" + @title = t(:series) respond_to do |format| format.html format.js diff --git a/app/models/book.rb b/app/models/book.rb index 7130beb..e9aa5b8 100644 --- a/app/models/book.rb +++ b/app/models/book.rb @@ -1,5 +1,6 @@ class Book < ActiveRecord::Base establish_connection Rails.configuration.database_configuration["calibre"] + scope :in_serie, -> { order(:series_index) } has_and_belongs_to_many :authors, join_table: "books_authors_link", diff --git a/app/views/series/show.html.erb b/app/views/series/show.html.erb index dd1b036..a10b00b 100644 --- a/app/views/series/show.html.erb +++ b/app/views/series/show.html.erb @@ -9,7 +9,7 @@ <%= t(:serie_book, count: @serie.books.count) %>