diff --git a/.Gemfile.swp b/.Gemfile.swp index 4af8a39..e0ef2c9 100644 Binary files a/.Gemfile.swp and b/.Gemfile.swp differ diff --git a/Gemfile b/Gemfile index 679e082..6748838 100644 --- a/Gemfile +++ b/Gemfile @@ -1,6 +1,9 @@ source 'https://rubygems.org' -gem 'magic_multi_connections' +#gem 'magic_multi_connections' +gem 'will_paginate' +#gem 'bootstrap-will_paginate' + # Bundle edge Rails instead: gem 'rails', github: 'rails/rails' gem 'rails', '4.2.2' diff --git a/Gemfile.lock b/Gemfile.lock index 6096249..edf97d0 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -66,7 +66,6 @@ GEM json (1.8.3) loofah (2.0.2) nokogiri (>= 1.5.9) - magic_multi_connections (1.2.1) mail (2.6.3) mime-types (>= 1.16, < 3) mime-types (2.6.1) @@ -138,6 +137,7 @@ GEM binding_of_caller (>= 0.7.2) railties (>= 4.0) sprockets-rails (>= 2.0, < 4.0) + will_paginate (3.0.7) PLATFORMS ruby @@ -147,7 +147,6 @@ DEPENDENCIES coffee-rails (~> 4.1.0) jbuilder (~> 2.0) jquery-rails - magic_multi_connections rails (= 4.2.2) sass-rails (~> 5.0) sdoc (~> 0.4.0) @@ -156,6 +155,7 @@ DEPENDENCIES turbolinks uglifier (>= 1.3.0) web-console (~> 2.0) + will_paginate BUNDLED WITH 1.10.4 diff --git a/app/controllers/books_controller.rb b/app/controllers/books_controller.rb index 1a0d2cf..4b7aae8 100644 --- a/app/controllers/books_controller.rb +++ b/app/controllers/books_controller.rb @@ -1,7 +1,11 @@ class BooksController < ApplicationController def show - @book = Calibre::Book.find(params[:id]) + @book = Book.find(params[:id]) + end + + def index + @books = Book.paginate(page: params[:page]) end end diff --git a/app/controllers/static_pages_controller.rb b/app/controllers/static_pages_controller.rb index 486c329..5cb4c92 100644 --- a/app/controllers/static_pages_controller.rb +++ b/app/controllers/static_pages_controller.rb @@ -1,7 +1,7 @@ class StaticPagesController < ApplicationController def home @title = "Home" - @books_count = Calibre::Book.count + @books_count = Book.count end def about diff --git a/app/models/book.rb b/app/models/book.rb index 6f68b44..0044c2f 100644 --- a/app/models/book.rb +++ b/app/models/book.rb @@ -1,2 +1,3 @@ class Book < ActiveRecord::Base + establish_connection Rails.configuration.database_configuration["calibre"] end diff --git a/app/views/books/index.html.erb b/app/views/books/index.html.erb new file mode 100644 index 0000000..0c1deac --- /dev/null +++ b/app/views/books/index.html.erb @@ -0,0 +1,14 @@ +

All books

+ +<%= will_paginate %> + + + +<%= will_paginate %> + diff --git a/config/environment.rb b/config/environment.rb index 87d119e..e0e72d2 100644 --- a/config/environment.rb +++ b/config/environment.rb @@ -6,8 +6,3 @@ Rails.application.initialize! ENV['GEM_PATH']='/home/meutel/gems/:/usr/local/lib/ruby/gems/2.1/' ENV['GEM_HOME']='/home/meutel/gems' -require 'magic_multi_connections' - -module Calibre - establish_connection :calibre -end