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 before_action :preferences, only: :index
def show def show
@serie = Serie.find(params[:id]) @serie = Serie.includes(books: :authors).references(:book).find(params[:id])
@title = @serie.name @title = @serie.name
end end
@ -14,7 +14,7 @@ class SeriesController < ApplicationController
.references(:books) .references(:books)
.order(:sort) .order(:sort)
.paginate(pagination) .paginate(pagination)
@title = "Series" @title = t(:series)
respond_to do |format| respond_to do |format|
format.html format.html
format.js format.js

View File

@ -1,5 +1,6 @@
class Book < ActiveRecord::Base class Book < ActiveRecord::Base
establish_connection Rails.configuration.database_configuration["calibre"] establish_connection Rails.configuration.database_configuration["calibre"]
scope :in_serie, -> { order(:series_index) }
has_and_belongs_to_many :authors, has_and_belongs_to_many :authors,
join_table: "books_authors_link", join_table: "books_authors_link",

View File

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