books index and simple db configuration

This commit is contained in:
Meutel 2015-06-28 14:59:37 +02:00
parent ea6326612a
commit 03b1010149
8 changed files with 27 additions and 10 deletions

Binary file not shown.

View File

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

View File

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

View File

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

View File

@ -1,7 +1,7 @@
class StaticPagesController < ApplicationController
def home
@title = "Home"
@books_count = Calibre::Book.count
@books_count = Book.count
end
def about

View File

@ -1,2 +1,3 @@
class Book < ActiveRecord::Base
establish_connection Rails.configuration.database_configuration["calibre"]
end

View File

@ -0,0 +1,14 @@
<h1>All books</h1>
<%= will_paginate %>
<ul class="books">
<% @books.each do |book| %>
<li>
<%= link_to book.title, book %>
</li>
<% end %>
</ul>
<%= will_paginate %>

View File

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