From dc750eb188fcfa5ce95400246e1b447092d0f2a5 Mon Sep 17 00:00:00 2001 From: Meutel Date: Sun, 28 Jun 2015 17:14:47 +0200 Subject: [PATCH] show,index series,authors --- app/assets/javascripts/authors.coffee | 3 +++ app/assets/javascripts/series.coffee | 3 +++ app/assets/stylesheets/authors.scss | 3 +++ app/assets/stylesheets/series.scss | 3 +++ app/controllers/authors_controller.rb | 13 +++++++++++++ app/controllers/series_controller.rb | 13 +++++++++++++ app/helpers/authors_helper.rb | 2 ++ app/helpers/series_helper.rb | 2 ++ app/views/authors/index.html.erb | 11 +++++++++++ app/views/authors/show.html.erb | 1 + app/views/books/show.html.erb | 1 + app/views/series/index.html.erb | 11 +++++++++++ app/views/series/show.html.erb | 6 ++++++ config/initializers/time_formats.rb | 1 + config/routes.rb | 2 ++ test/controllers/authors_controller_test.rb | 7 +++++++ test/controllers/series_controller_test.rb | 7 +++++++ 17 files changed, 89 insertions(+) create mode 100644 app/assets/javascripts/authors.coffee create mode 100644 app/assets/javascripts/series.coffee create mode 100644 app/assets/stylesheets/authors.scss create mode 100644 app/assets/stylesheets/series.scss create mode 100644 app/controllers/authors_controller.rb create mode 100644 app/controllers/series_controller.rb create mode 100644 app/helpers/authors_helper.rb create mode 100644 app/helpers/series_helper.rb create mode 100644 app/views/authors/index.html.erb create mode 100644 app/views/authors/show.html.erb create mode 100644 app/views/series/index.html.erb create mode 100644 app/views/series/show.html.erb create mode 100644 config/initializers/time_formats.rb create mode 100644 test/controllers/authors_controller_test.rb create mode 100644 test/controllers/series_controller_test.rb diff --git a/app/assets/javascripts/authors.coffee b/app/assets/javascripts/authors.coffee new file mode 100644 index 0000000..24f83d1 --- /dev/null +++ b/app/assets/javascripts/authors.coffee @@ -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/ diff --git a/app/assets/javascripts/series.coffee b/app/assets/javascripts/series.coffee new file mode 100644 index 0000000..24f83d1 --- /dev/null +++ b/app/assets/javascripts/series.coffee @@ -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/ diff --git a/app/assets/stylesheets/authors.scss b/app/assets/stylesheets/authors.scss new file mode 100644 index 0000000..fb565e9 --- /dev/null +++ b/app/assets/stylesheets/authors.scss @@ -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/ diff --git a/app/assets/stylesheets/series.scss b/app/assets/stylesheets/series.scss new file mode 100644 index 0000000..c8265b6 --- /dev/null +++ b/app/assets/stylesheets/series.scss @@ -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/ diff --git a/app/controllers/authors_controller.rb b/app/controllers/authors_controller.rb new file mode 100644 index 0000000..533b782 --- /dev/null +++ b/app/controllers/authors_controller.rb @@ -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 diff --git a/app/controllers/series_controller.rb b/app/controllers/series_controller.rb new file mode 100644 index 0000000..eb28280 --- /dev/null +++ b/app/controllers/series_controller.rb @@ -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 diff --git a/app/helpers/authors_helper.rb b/app/helpers/authors_helper.rb new file mode 100644 index 0000000..f22e1f9 --- /dev/null +++ b/app/helpers/authors_helper.rb @@ -0,0 +1,2 @@ +module AuthorsHelper +end diff --git a/app/helpers/series_helper.rb b/app/helpers/series_helper.rb new file mode 100644 index 0000000..57f0452 --- /dev/null +++ b/app/helpers/series_helper.rb @@ -0,0 +1,2 @@ +module SeriesHelper +end diff --git a/app/views/authors/index.html.erb b/app/views/authors/index.html.erb new file mode 100644 index 0000000..322eff1 --- /dev/null +++ b/app/views/authors/index.html.erb @@ -0,0 +1,11 @@ +

Authors

+ +<%= will_paginate %> + + + +<%= will_paginate %> diff --git a/app/views/authors/show.html.erb b/app/views/authors/show.html.erb new file mode 100644 index 0000000..db6dddd --- /dev/null +++ b/app/views/authors/show.html.erb @@ -0,0 +1 @@ +

<%= @author.name %>

diff --git a/app/views/books/show.html.erb b/app/views/books/show.html.erb index 2c1b3a4..f5a10cd 100644 --- a/app/views/books/show.html.erb +++ b/app/views/books/show.html.erb @@ -16,3 +16,4 @@

Serie: <%= @book.serie.name %>

Publisher: <%= @book.publisher.name %>

+

Publishing date: <%= @book.pubdate.to_formatted_s(:date) %>

diff --git a/app/views/series/index.html.erb b/app/views/series/index.html.erb new file mode 100644 index 0000000..a2241fa --- /dev/null +++ b/app/views/series/index.html.erb @@ -0,0 +1,11 @@ +

Series

+ +<%= will_paginate %> + + + +<%= will_paginate %> diff --git a/app/views/series/show.html.erb b/app/views/series/show.html.erb new file mode 100644 index 0000000..2cbc211 --- /dev/null +++ b/app/views/series/show.html.erb @@ -0,0 +1,6 @@ +

<%= @serie.name %>

+ diff --git a/config/initializers/time_formats.rb b/config/initializers/time_formats.rb new file mode 100644 index 0000000..f86be84 --- /dev/null +++ b/config/initializers/time_formats.rb @@ -0,0 +1 @@ +Time::DATE_FORMATS[:date] = '%Y-%m-%d' diff --git a/config/routes.rb b/config/routes.rb index 29050c8..dfefb48 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -4,6 +4,8 @@ Rails.application.routes.draw do get 'static_pages/about' resources :books + resources :authors + resources :series # The priority is based upon order of creation: first created -> highest priority. # See how all your routes lay out with "rake routes". diff --git a/test/controllers/authors_controller_test.rb b/test/controllers/authors_controller_test.rb new file mode 100644 index 0000000..3befa01 --- /dev/null +++ b/test/controllers/authors_controller_test.rb @@ -0,0 +1,7 @@ +require 'test_helper' + +class AuthorsControllerTest < ActionController::TestCase + # test "the truth" do + # assert true + # end +end diff --git a/test/controllers/series_controller_test.rb b/test/controllers/series_controller_test.rb new file mode 100644 index 0000000..e29ebaf --- /dev/null +++ b/test/controllers/series_controller_test.rb @@ -0,0 +1,7 @@ +require 'test_helper' + +class SeriesControllerTest < ActionController::TestCase + # test "the truth" do + # assert true + # end +end