diff --git a/Gemfile b/Gemfile index 13d617ca23..827c360d22 100644 --- a/Gemfile +++ b/Gemfile @@ -35,12 +35,16 @@ gem 'sdoc', '~> 0.4.0', group: :doc group :development, :test do # Call 'byebug' anywhere in the code to stop execution and get a debugger console gem 'byebug' - gem 'better_errors' +end + +group :test do + gem 'minitest-reporters' end group :development do # Access an IRB console on exception pages or by using <%= console %> in views gem 'web-console', '~> 2.0' + gem 'better_errors' # Spring speeds up development by keeping your application running in the background. Read more: https://github.com/rails/spring gem 'spring' diff --git a/Gemfile.lock b/Gemfile.lock index 2516d4acd5..8605f91ef5 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -36,11 +36,17 @@ GEM minitest (~> 5.1) thread_safe (~> 0.3, >= 0.3.4) tzinfo (~> 1.1) + ansi (1.5.0) arel (6.0.3) + better_errors (2.1.1) + coderay (>= 1.0.0) + erubis (>= 2.6.6) + rack (>= 0.9.0) binding_of_caller (0.7.2) debug_inspector (>= 0.0.1) builder (3.2.2) byebug (9.0.6) + coderay (1.1.1) coffee-rails (4.1.1) coffee-script (>= 2.2.0) railties (>= 4.0.0, < 5.1.x) @@ -72,6 +78,11 @@ GEM mime-types-data (3.2016.0521) mini_portile2 (2.1.0) minitest (5.9.1) + minitest-reporters (1.1.11) + ansi + builder + minitest (>= 5.0) + ruby-progressbar multi_json (1.12.1) nokogiri (1.6.8.1) mini_portile2 (~> 2.1.0) @@ -105,6 +116,7 @@ GEM rake (11.3.0) rdoc (4.2.2) json (~> 1.4) + ruby-progressbar (1.8.1) sass (3.4.22) sass-rails (5.0.6) railties (>= 4.0.0, < 6) @@ -145,10 +157,12 @@ PLATFORMS ruby DEPENDENCIES + better_errors byebug coffee-rails (~> 4.1.0) jbuilder (~> 2.0) jquery-rails + minitest-reporters rails (= 4.2.7) sass-rails (~> 5.0) sdoc (~> 0.4.0) diff --git a/app/assets/images/owl.jpg b/app/assets/images/owl.jpg new file mode 100644 index 0000000000..b3ded30950 Binary files /dev/null and b/app/assets/images/owl.jpg differ diff --git a/app/assets/javascripts/albums.coffee b/app/assets/javascripts/albums.coffee new file mode 100644 index 0000000000..24f83d18bb --- /dev/null +++ b/app/assets/javascripts/albums.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/books.coffee b/app/assets/javascripts/books.coffee new file mode 100644 index 0000000000..24f83d18bb --- /dev/null +++ b/app/assets/javascripts/books.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/homes.coffee b/app/assets/javascripts/homes.coffee new file mode 100644 index 0000000000..24f83d18bb --- /dev/null +++ b/app/assets/javascripts/homes.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/movies.coffee b/app/assets/javascripts/movies.coffee new file mode 100644 index 0000000000..24f83d18bb --- /dev/null +++ b/app/assets/javascripts/movies.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/albums.scss b/app/assets/stylesheets/albums.scss new file mode 100644 index 0000000000..684cc4c17f --- /dev/null +++ b/app/assets/stylesheets/albums.scss @@ -0,0 +1,3 @@ +// Place all the styles related to the Albums 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/books.scss b/app/assets/stylesheets/books.scss new file mode 100644 index 0000000000..9fab565c8d --- /dev/null +++ b/app/assets/stylesheets/books.scss @@ -0,0 +1,3 @@ +// Place all the styles related to the Books 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/homes.scss b/app/assets/stylesheets/homes.scss new file mode 100644 index 0000000000..06b5a4714a --- /dev/null +++ b/app/assets/stylesheets/homes.scss @@ -0,0 +1,3 @@ +// Place all the styles related to the Homes 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/movies.scss b/app/assets/stylesheets/movies.scss new file mode 100644 index 0000000000..b86dfedb53 --- /dev/null +++ b/app/assets/stylesheets/movies.scss @@ -0,0 +1,3 @@ +// Place all the styles related to the Movies 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/albums_controller.rb b/app/controllers/albums_controller.rb new file mode 100644 index 0000000000..e53d80af63 --- /dev/null +++ b/app/controllers/albums_controller.rb @@ -0,0 +1,59 @@ +class AlbumsController < ApplicationController + def index + @albums = Album.all + @albums_by_rank = Album.order(:rank).reverse + + end + + def new + @album = Album.new + end + + def create + @album = Album.new(album_params) + if @album.save + redirect_to albums_path + else + render :new + end + end + + def edit + @album = Album.find(params[:id]) + end + + def update + @album = Album.find(params[:id]) + if @album.update(album_params) + redirect_to albums_path + else + render :edit + end + + end + + def destroy + @album = Album.find(params[:id]) + @album.destroy + redirect_to album_path + end + + def show + @album = Album.find(params[:id]) + end + + def upvote + @album = Album.find(params[:id]) + @album.rank += 1 + @album.save + redirect_to :back + end + + private + + def album_params + params.require(:album).permit(:name, :artist, :description) #do i want :rank ? + end + + +end diff --git a/app/controllers/books_controller.rb b/app/controllers/books_controller.rb new file mode 100644 index 0000000000..2c148170e1 --- /dev/null +++ b/app/controllers/books_controller.rb @@ -0,0 +1,57 @@ +class BooksController < ApplicationController + def index + @books = Book.all + @books_by_rank = Book.order(:rank).reverse + end + + def new + @book = Book.new + end + + def create + @book = Book.new(book_params) + if @book.save + redirect_to books_path + else + render :new + end + end + + def edit + @book = Book.find(params[:id]) + end + + def update + @book = Book.find(params[:id]) + if @book.update(book_params) + redirect_to books_path + else + render :edit + end + end + + def destroy + @book = Book.find(params[:id]) + @book.destroy + redirect_to book_path + end + + def show + @book = Book.find(params[:id]) + end + + def upvote + @book = Book.find(params[:id]) + @book.rank += 1 + @book.save + redirect_to :back + end + + private + + def book_params + params.require(:book).permit(:name, :author, :description) #do i want :rank ? + end + + +end diff --git a/app/controllers/homes_controller.rb b/app/controllers/homes_controller.rb new file mode 100644 index 0000000000..1121c2bbc0 --- /dev/null +++ b/app/controllers/homes_controller.rb @@ -0,0 +1,7 @@ +class HomesController < ApplicationController + def index + @movies_by_rank = Movie.order(:rank).reverse + @books_by_rank = Book.order(:rank).reverse + @albums_by_rank = Album.order(:rank).reverse + end +end diff --git a/app/controllers/movies_controller.rb b/app/controllers/movies_controller.rb new file mode 100644 index 0000000000..03c6dced82 --- /dev/null +++ b/app/controllers/movies_controller.rb @@ -0,0 +1,60 @@ +class MoviesController < ApplicationController + def index + @movies = Movie.all + @movies_by_rank = Movie.order(:rank).reverse + + end + + def new + @movie = Movie.new + end + + def create + @movie = Movie.new(movie_params) + if @movie.save + redirect_to movies_path + else + render :new + end + end + + def edit + @movie = Movie.find(params[:id]) + end + + def update + @movie = Movie.find(params[:id]) + if @movie.update(movie_params) + redirect_to movies_path + else + render :edit + end + + end + + def destroy + @movie = Movie.find(params[:id]) + @movie.destroy + redirect_to movie_path + end + + def show + @movie = Movie.find(params[:id]) + end + + def upvote + @movie = Movie.find(params[:id]) + @movie.rank += 1 + @movie.save + + redirect_to :back + end + + + private + + def movie_params + params.require(:movie).permit(:name, :director, :description) #do i want :rank ? + end + +end diff --git a/app/helpers/albums_helper.rb b/app/helpers/albums_helper.rb new file mode 100644 index 0000000000..d976b7cef8 --- /dev/null +++ b/app/helpers/albums_helper.rb @@ -0,0 +1,2 @@ +module AlbumsHelper +end diff --git a/app/helpers/books_helper.rb b/app/helpers/books_helper.rb new file mode 100644 index 0000000000..4b9311e0be --- /dev/null +++ b/app/helpers/books_helper.rb @@ -0,0 +1,2 @@ +module BooksHelper +end diff --git a/app/helpers/homes_helper.rb b/app/helpers/homes_helper.rb new file mode 100644 index 0000000000..2a8ce49d58 --- /dev/null +++ b/app/helpers/homes_helper.rb @@ -0,0 +1,2 @@ +module HomesHelper +end diff --git a/app/helpers/movies_helper.rb b/app/helpers/movies_helper.rb new file mode 100644 index 0000000000..493eee555f --- /dev/null +++ b/app/helpers/movies_helper.rb @@ -0,0 +1,2 @@ +module MoviesHelper +end diff --git a/app/models/album.rb b/app/models/album.rb new file mode 100644 index 0000000000..253ea39f93 --- /dev/null +++ b/app/models/album.rb @@ -0,0 +1,6 @@ +class Album < ActiveRecord::Base + + validates :name, presence: true + validates :artist, presence: true + +end diff --git a/app/models/book.rb b/app/models/book.rb new file mode 100644 index 0000000000..b5819f18c3 --- /dev/null +++ b/app/models/book.rb @@ -0,0 +1,6 @@ +class Book < ActiveRecord::Base + + validates :name, presence: true + validates :author, presence: true + +end diff --git a/app/models/movie.rb b/app/models/movie.rb new file mode 100644 index 0000000000..08ffa94347 --- /dev/null +++ b/app/models/movie.rb @@ -0,0 +1,6 @@ +class Movie < ActiveRecord::Base + + validates :name, presence: true + validates :director, presence: true + +end diff --git a/app/views/albums/_form.html.erb b/app/views/albums/_form.html.erb new file mode 100644 index 0000000000..672fb7accf --- /dev/null +++ b/app/views/albums/_form.html.erb @@ -0,0 +1,20 @@ +<% if @album.errors.any? %> +
| Ranking | +Name | +Upvote | +
|---|---|---|
| <%= " #{album.rank}" %> | +<%= link_to "#{album.name}", album_path(album.id)%> | +<%= button_to "Upvote", upvote_album_path(album), method: :patch %> | +
<%= "#{@album.description}" %>
+ + +| Ranking | +Name | +Upvote | +
|---|---|---|
| <%= " #{book.rank}" %> | +<%= link_to "#{book.name}", book_path(book.id)%> | +<%= button_to "Upvote", upvote_book_path(book), method: :patch %> | +
<%= "#{@book.description}" %>
+ + +| Top Movies | +Top Books | +Top Albums | +
|---|---|---|
| <%= link_to "#{@movies_by_rank[i].name}", movie_path(@movies_by_rank[i].id)%><%= " #{@movies_by_rank[i].rank}" %> | + +<%= link_to "#{@books_by_rank[i].name}", book_path(@books_by_rank[i].id)%><%= " #{@books_by_rank[i].rank}" %> | + +<%= link_to "#{@albums_by_rank[i].name}", album_path(@albums_by_rank[i].id)%><%= " #{@albums_by_rank[i].rank}" %> | +
| + <%= link_to "View More Movies", movies_path %> + + | ++ <%= link_to "View More Books", books_path %> + + | ++ <%= link_to "View More Albums", albums_path %> + + | +