order books in serie

This commit is contained in:
Meutel 2015-08-14 10:10:22 +02:00
parent d2a8faad93
commit 46f6c55906
3 changed files with 4 additions and 3 deletions

View File

@ -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

View File

@ -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",

View File

@ -9,7 +9,7 @@
<%= t(:serie_book, count: @serie.books.count) %>
</h2>
<ul>
<% @serie.books.each do |book| %>
<% @serie.books.in_serie.each do |book| %>
<li><%= book.series_index.to_i %>. <%= link_to book.title, book %></li>
<% end %>
</ul>