books index and simple db configuration
This commit is contained in:
parent
ea6326612a
commit
03b1010149
BIN
.Gemfile.swp
BIN
.Gemfile.swp
Binary file not shown.
5
Gemfile
5
Gemfile
@ -1,6 +1,9 @@
|
|||||||
source 'https://rubygems.org'
|
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'
|
# Bundle edge Rails instead: gem 'rails', github: 'rails/rails'
|
||||||
gem 'rails', '4.2.2'
|
gem 'rails', '4.2.2'
|
||||||
|
@ -66,7 +66,6 @@ GEM
|
|||||||
json (1.8.3)
|
json (1.8.3)
|
||||||
loofah (2.0.2)
|
loofah (2.0.2)
|
||||||
nokogiri (>= 1.5.9)
|
nokogiri (>= 1.5.9)
|
||||||
magic_multi_connections (1.2.1)
|
|
||||||
mail (2.6.3)
|
mail (2.6.3)
|
||||||
mime-types (>= 1.16, < 3)
|
mime-types (>= 1.16, < 3)
|
||||||
mime-types (2.6.1)
|
mime-types (2.6.1)
|
||||||
@ -138,6 +137,7 @@ GEM
|
|||||||
binding_of_caller (>= 0.7.2)
|
binding_of_caller (>= 0.7.2)
|
||||||
railties (>= 4.0)
|
railties (>= 4.0)
|
||||||
sprockets-rails (>= 2.0, < 4.0)
|
sprockets-rails (>= 2.0, < 4.0)
|
||||||
|
will_paginate (3.0.7)
|
||||||
|
|
||||||
PLATFORMS
|
PLATFORMS
|
||||||
ruby
|
ruby
|
||||||
@ -147,7 +147,6 @@ DEPENDENCIES
|
|||||||
coffee-rails (~> 4.1.0)
|
coffee-rails (~> 4.1.0)
|
||||||
jbuilder (~> 2.0)
|
jbuilder (~> 2.0)
|
||||||
jquery-rails
|
jquery-rails
|
||||||
magic_multi_connections
|
|
||||||
rails (= 4.2.2)
|
rails (= 4.2.2)
|
||||||
sass-rails (~> 5.0)
|
sass-rails (~> 5.0)
|
||||||
sdoc (~> 0.4.0)
|
sdoc (~> 0.4.0)
|
||||||
@ -156,6 +155,7 @@ DEPENDENCIES
|
|||||||
turbolinks
|
turbolinks
|
||||||
uglifier (>= 1.3.0)
|
uglifier (>= 1.3.0)
|
||||||
web-console (~> 2.0)
|
web-console (~> 2.0)
|
||||||
|
will_paginate
|
||||||
|
|
||||||
BUNDLED WITH
|
BUNDLED WITH
|
||||||
1.10.4
|
1.10.4
|
||||||
|
@ -1,7 +1,11 @@
|
|||||||
class BooksController < ApplicationController
|
class BooksController < ApplicationController
|
||||||
|
|
||||||
def show
|
def show
|
||||||
@book = Calibre::Book.find(params[:id])
|
@book = Book.find(params[:id])
|
||||||
|
end
|
||||||
|
|
||||||
|
def index
|
||||||
|
@books = Book.paginate(page: params[:page])
|
||||||
end
|
end
|
||||||
|
|
||||||
end
|
end
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
class StaticPagesController < ApplicationController
|
class StaticPagesController < ApplicationController
|
||||||
def home
|
def home
|
||||||
@title = "Home"
|
@title = "Home"
|
||||||
@books_count = Calibre::Book.count
|
@books_count = Book.count
|
||||||
end
|
end
|
||||||
|
|
||||||
def about
|
def about
|
||||||
|
@ -1,2 +1,3 @@
|
|||||||
class Book < ActiveRecord::Base
|
class Book < ActiveRecord::Base
|
||||||
|
establish_connection Rails.configuration.database_configuration["calibre"]
|
||||||
end
|
end
|
||||||
|
14
app/views/books/index.html.erb
Normal file
14
app/views/books/index.html.erb
Normal 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 %>
|
||||||
|
|
@ -6,8 +6,3 @@ Rails.application.initialize!
|
|||||||
|
|
||||||
ENV['GEM_PATH']='/home/meutel/gems/:/usr/local/lib/ruby/gems/2.1/'
|
ENV['GEM_PATH']='/home/meutel/gems/:/usr/local/lib/ruby/gems/2.1/'
|
||||||
ENV['GEM_HOME']='/home/meutel/gems'
|
ENV['GEM_HOME']='/home/meutel/gems'
|
||||||
require 'magic_multi_connections'
|
|
||||||
|
|
||||||
module Calibre
|
|
||||||
establish_connection :calibre
|
|
||||||
end
|
|
||||||
|
Loading…
Reference in New Issue
Block a user