forked from AdaGold/media-ranker
-
Notifications
You must be signed in to change notification settings - Fork 21
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Submitting MediaRanker #31
Open
emgord
wants to merge
38
commits into
Ada-C4:erg/master
Choose a base branch
from
emgord:erg/master
base: erg/master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
38 commits
Select commit
Hold shift + click to select a range
36502ae
Created models and controllers for movies, books and albums
emgord 8a74a2b
oops forgot to save, igrated db again
emgord 5dcc343
added resources routes for movies, books and albums
emgord 5ef1452
added index page for movies
emgord a98198e
added new and create method for movie
emgord 7ace56f
created show page for movie
emgord 196dc63
added edit and update for movies
emgord 64740ef
added Delete method for movies
emgord e6c3c7e
added upvote function to movie detail page
emgord 538cbf5
added upvote to main movie page and sorted by rank
emgord e238363
created partial for index page
emgord 49ff71d
added index for books
emgord 172608c
added index for albums, seed data, and upvote for albums and books
emgord 98db05d
added rspec
emgord e9c0d4e
added validation for name on movies
emgord 2271b5f
added simplecov
emgord 05ecd42
adding specs for movie controller
emgord 6ee89b1
added spec for upvote
emgord 6c4a425
added bootstrap styling
emgord aee69fa
added home controller and page
emgord c87dae5
added home page, still need to rank media and only show top 10
emgord bdaefc4
ranked and grabbed top ten for home page, added general medium spec a…
emgord 48a9306
successfully created shared spec for movie
emgord 6bc50d1
added spec to validate presence of name for album and book, and valid…
emgord 1206892
movied all movie specs to shared specs
emgord 0b5d70a
added tests for books and albums
emgord a23f32a
added test for home controller
emgord 53d5b93
updated form partial so it can be used for all media.
emgord f266666
added new and create for album and book
emgord 411d76c
created partial for the show and got it working for movie
emgord 18bc3a1
added show for albums and books
emgord b768ce9
added edit method for album and books
emgord 333f716
added delete for albums and movies
emgord dea3373
fixed typos and got all specs working
emgord e39af02
double checked that styling is all the same, made a few small changes
emgord 346df5c
added test to make sure update is actually changing as expected, and …
emgord 24db221
project complete
emgord 6d95929
just kidding. added validation for max length of name, description an…
emgord File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -15,3 +15,5 @@ | |
/log/* | ||
!/log/.keep | ||
/tmp | ||
|
||
coverage |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
--color | ||
--require spec_helper |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
// Place all the styles related to the album controller here. | ||
// They will automatically be included in application.css. | ||
// You can use Sass (SCSS) here: http://sass-lang.com/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
// Place all the styles related to the home controller here. | ||
// They will automatically be included in application.css. | ||
// You can use Sass (SCSS) here: http://sass-lang.com/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,56 @@ | ||
class AlbumsController < ApplicationController | ||
|
||
def index | ||
@albums = Album.all.sort_by { |album| -album.rank } | ||
end | ||
|
||
def upvote | ||
album = Album.find(params[:id]) | ||
album.rank += 1 | ||
album.save | ||
redirect_to album_path(album) | ||
end | ||
|
||
def new | ||
@album = Album.new | ||
end | ||
|
||
def create | ||
@album = Album.new(album_params[:album]) | ||
if @album.save | ||
redirect_to album_path(@album) | ||
else | ||
render "new" | ||
end | ||
end | ||
|
||
def show | ||
@album = Album.find(params[:id]) | ||
end | ||
|
||
def edit | ||
@album = Album.find(params[:id]) | ||
end | ||
|
||
def update | ||
@album = Album.find(params[:id]) | ||
@album.update( album_params[:album]) | ||
if @album.save | ||
redirect_to album_path(@album) | ||
else | ||
render "edit" | ||
end | ||
end | ||
|
||
def destroy | ||
Album.destroy(params[:id]) | ||
redirect_to albums_path | ||
end | ||
|
||
private | ||
|
||
def album_params | ||
params.permit(album:[:name, :artist, :description, :rank]) | ||
end | ||
|
||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,57 @@ | ||
class BooksController < ApplicationController | ||
|
||
def index | ||
@books = Book.all.sort_by { |book| -book.rank } | ||
end | ||
|
||
def upvote | ||
book = Book.find(params[:id]) | ||
book.rank += 1 | ||
book.save | ||
redirect_to book_path(book) | ||
end | ||
|
||
def new | ||
@book = Book.new | ||
end | ||
|
||
def create | ||
@book = Book.new(book_params) | ||
if @book.save | ||
redirect_to book_path(@book) | ||
else | ||
render "new" | ||
end | ||
end | ||
|
||
def show | ||
@book = Book.find(params[:id]) | ||
end | ||
|
||
def edit | ||
@book = Book.find(params[:id]) | ||
end | ||
|
||
def update | ||
@book = Book.find(params[:id]) | ||
@book.update( book_params ) | ||
if @book.save | ||
redirect_to book_path(@book) | ||
else | ||
render "edit" | ||
end | ||
end | ||
|
||
def destroy | ||
Book.destroy(params[:id]) | ||
redirect_to books_path | ||
end | ||
|
||
private | ||
|
||
def book_params | ||
params.require(:book).permit(:name, :author, :description, :rank) | ||
end | ||
|
||
|
||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
class HomeController < ApplicationController | ||
|
||
def index | ||
@movies = Movie.all.sort_by { |movie| -movie.rank }.first(10) | ||
@albums = Album.all.sort_by { |album| -album.rank }.first(10) | ||
@books = Book.all.sort_by { |book| -book.rank }.first(10) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. If this application had to be maintained (and expanded to other media types) in the future, this would be a great case for using a constant to store the |
||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,57 @@ | ||
class MoviesController < ApplicationController | ||
|
||
def index | ||
@movies = Movie.all.sort_by { |movie| -movie.rank } | ||
end | ||
|
||
def new | ||
@movie = Movie.new | ||
end | ||
|
||
def create | ||
@movie = Movie.new(movie_params[:movie]) | ||
if @movie.save | ||
redirect_to movie_path(@movie) | ||
else | ||
render "new" | ||
end | ||
end | ||
|
||
def show | ||
@movie = Movie.find(params[:id]) | ||
end | ||
|
||
def edit | ||
@movie = Movie.find(params[:id]) | ||
end | ||
|
||
def update | ||
@movie = Movie.find(params[:id]) | ||
@movie.update( movie_params[:movie]) | ||
if @movie.save | ||
redirect_to movie_path(@movie) | ||
else | ||
render "edit" | ||
end | ||
end | ||
|
||
def destroy | ||
Movie.destroy(params[:id]) | ||
redirect_to movies_path | ||
end | ||
|
||
def upvote | ||
movie = Movie.find(params[:id]) | ||
movie.rank += 1 | ||
movie.save | ||
redirect_to movie_path(movie) | ||
end | ||
|
||
private | ||
|
||
def movie_params | ||
params.permit(movie:[:name, :director, :description, :rank]) | ||
end | ||
|
||
|
||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
module AlbumHelper | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
module BooksHelper | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
module HomeHelper | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
module MoviesHelper | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
class Album < ActiveRecord::Base | ||
validates :name, presence: true, length: { maximum: 100 } | ||
validates :description, length: {maximum: 500 } | ||
validates :artist, length: {maximum: 100 } | ||
|
||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
class Book < ActiveRecord::Base | ||
validates :name, presence: true, length: { maximum: 100 } | ||
validates :description, length: {maximum: 500 } | ||
validates :author, length: {maximum: 100 } | ||
|
||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
class Movie < ActiveRecord::Base | ||
validates :name, presence: true, length: { maximum: 100 } | ||
validates :description, length: {maximum: 500 } | ||
validates :director, length: {maximum: 100 } | ||
|
||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
<%= render partial:'shared/form', | ||
locals:{ medium: @album, action: :update, title: "Edit Album", creator: :artist, rank_value: @album.rank} %> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
<%= render partial:'shared/index', | ||
locals:{media:@albums, media_type: :album } %> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
<%= render partial:'shared/form', | ||
locals:{ medium: @album, action: :create, title: "New Album", creator: :artist, rank_value: 0} %> |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
👍 There's also a cool
.increment!
method that does the same thing as lines 9-10.