order books in serie
This commit is contained in:
parent
d2a8faad93
commit
46f6c55906
@ -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
|
||||||
|
@ -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",
|
||||||
|
@ -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>
|
||||||
|
Loading…
Reference in New Issue
Block a user