show,index series,authors

This commit is contained in:
Meutel 2015-06-28 17:14:47 +02:00
parent 5ee2ea8e48
commit dc750eb188
17 changed files with 89 additions and 0 deletions

View File

@ -0,0 +1,3 @@
# Place all the behaviors and hooks related to the matching controller here.
# All this logic will automatically be available in application.js.
# You can use CoffeeScript in this file: http://coffeescript.org/

View File

@ -0,0 +1,3 @@
# Place all the behaviors and hooks related to the matching controller here.
# All this logic will automatically be available in application.js.
# You can use CoffeeScript in this file: http://coffeescript.org/

View File

@ -0,0 +1,3 @@
// Place all the styles related to the authors controller here.
// They will automatically be included in application.css.
// You can use Sass (SCSS) here: http://sass-lang.com/

View File

@ -0,0 +1,3 @@
// Place all the styles related to the series controller here.
// They will automatically be included in application.css.
// You can use Sass (SCSS) here: http://sass-lang.com/

View File

@ -0,0 +1,13 @@
class AuthorsController < ApplicationController
def show
@author = Author.find(params[:id])
@title = @author.name
end
def index
@authors = Author.paginate(page: params[:page])
@title = "Authors"
end
end

View File

@ -0,0 +1,13 @@
class SeriesController < ApplicationController
def show
@serie = Serie.find(params[:id])
@title = @serie.name
end
def index
@series = Serie.paginate(page: params[:page])
@title = "Series"
end
end

View File

@ -0,0 +1,2 @@
module AuthorsHelper
end

View File

@ -0,0 +1,2 @@
module SeriesHelper
end

View File

@ -0,0 +1,11 @@
<h1>Authors</h1>
<%= will_paginate %>
<ul class="authors">
<% @authors.each do |author| %>
<li><%= link_to author.name, author %></li>
<% end %>
</ul>
<%= will_paginate %>

View File

@ -0,0 +1 @@
<h1><%= @author.name %></h1>

View File

@ -16,3 +16,4 @@
</ul> </ul>
<p>Serie: <%= @book.serie.name %></p> <p>Serie: <%= @book.serie.name %></p>
<p>Publisher: <%= @book.publisher.name %></p> <p>Publisher: <%= @book.publisher.name %></p>
<p>Publishing date: <%= @book.pubdate.to_formatted_s(:date) %></p>

View File

@ -0,0 +1,11 @@
<h1>Series</h1>
<%= will_paginate %>
<ul class="series">
<% @series.each do |serie| %>
<li><%= link_to serie.name, serie %></li>
<% end %>
</ul>
<%= will_paginate %>

View File

@ -0,0 +1,6 @@
<h1><%= @serie.name %></h1>
<ul>
<% @serie.books.each do |book| %>
<li><%= link_to book.title, book %></li>
<% end %>
</ul>

View File

@ -0,0 +1 @@
Time::DATE_FORMATS[:date] = '%Y-%m-%d'

View File

@ -4,6 +4,8 @@ Rails.application.routes.draw do
get 'static_pages/about' get 'static_pages/about'
resources :books resources :books
resources :authors
resources :series
# The priority is based upon order of creation: first created -> highest priority. # The priority is based upon order of creation: first created -> highest priority.
# See how all your routes lay out with "rake routes". # See how all your routes lay out with "rake routes".

View File

@ -0,0 +1,7 @@
require 'test_helper'
class AuthorsControllerTest < ActionController::TestCase
# test "the truth" do
# assert true
# end
end

View File

@ -0,0 +1,7 @@
require 'test_helper'
class SeriesControllerTest < ActionController::TestCase
# test "the truth" do
# assert true
# end
end