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
Final submission for final wave of Media Ranker #40
Open
trowbrsa
wants to merge
33
commits into
Ada-C4:sat/master
Choose a base branch
from
trowbrsa:sat/master
base: sat/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
33 commits
Select commit
Hold shift + click to select a range
f3b274d
Created Movie, Book and Album models
trowbrsa 7036302
generated books, movies and albums controllers
trowbrsa 68d1dd1
generated routes for 3 models
trowbrsa c74fa0c
Added all standard methods and views for movies controller
trowbrsa ee9a783
Added views and methods for books class
trowbrsa 510c87b
unworking method for upvotes
trowbrsa 05a1022
Working upvote method
trowbrsa 12b538d
Made a named route for upvote movie path, added link to movie index page
trowbrsa 5b1d254
Added specs for create, new, index methods
trowbrsa bea4a5f
Successfully created update spec for movies
trowbrsa 9b42653
Added Bootstrap
trowbrsa fc22e9b
Added simplecov gem
trowbrsa 81d52d2
Successfully created spec for update method
trowbrsa 4643c2d
Working method for upvote
trowbrsa c404605
Created test for testing incrementation and redirect of upvote method
trowbrsa 0a29eb8
Added additional bootstrap styling
trowbrsa 31616e0
Added errors message when title not included
trowbrsa ec1656a
Added new medium controller spec
trowbrsa 3bd514b
Added album views and controller methods
trowbrsa 9ea93de
Updated home view
trowbrsa 4c948e3
Updated show view for books
trowbrsa 8aeb300
Added method to show top 10 ranked items on home page
trowbrsa 92e7114
Added method for upvoting on show page of albums
trowbrsa bc45bef
Added additional bootstrap styling to show view
trowbrsa 233d91b
Added additional bootstrap styling
trowbrsa 06eb3ca
Generalized movie rspec tests to make availabel for all controllers
trowbrsa c29c608
Refined rspec tests to make them work
trowbrsa f4c2d6b
Wrote more tests for album and books controller
trowbrsa bee34d9
Updated bootstrap on home page
trowbrsa 0e3d975
Updated specs
trowbrsa 3885c21
Generalized all tests for each controller
trowbrsa 38203b4
Added bootstrap styling to 'show' view for all controllers
trowbrsa 9a2756d
Finalized 'edit' method for books and albums controller
trowbrsa 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.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
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 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/ |
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 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,68 @@ | ||
class AlbumsController < ApplicationController | ||
|
||
def index | ||
@albums = Album.all | ||
end | ||
|
||
def new | ||
@title = "Add an Album" | ||
@action = :create | ||
@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 | ||
id = params[:id] | ||
@album = Album.find(id) | ||
end | ||
|
||
def edit | ||
@title = "Edit an Album" | ||
id = params[:id] | ||
@album = Album.find(id) | ||
@action = :update | ||
end | ||
|
||
def update | ||
@value = params[:ranking] | ||
id = params[:id] | ||
@album = Album.find(id) | ||
@album.attributes = album_params[:album] | ||
if @album.save | ||
redirect_to album_path(params[:id]) | ||
else | ||
@title = "Edit an album" | ||
@action = :update | ||
render :edit | ||
end | ||
end | ||
|
||
def destroy | ||
Album.destroy(params[:id]) | ||
redirect_to albums_path | ||
end | ||
|
||
def upvote | ||
id = params[:id] | ||
album = Album.find(id) | ||
r = album.ranking | ||
r += 1 | ||
album.update(ranking: r) | ||
redirect_to :back | ||
end | ||
|
||
private | ||
|
||
def album_params | ||
params.permit(album:[:author, :title, :ranking, :description]) | ||
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,70 @@ | ||
class BooksController < ApplicationController | ||
def index | ||
@books = Book.all | ||
end | ||
|
||
def new | ||
@title = "Add a Book" | ||
@action = :create | ||
@book = Book.new | ||
end | ||
|
||
|
||
def create | ||
@title = "Add a book" | ||
@book = Book.new(book_params[:book]) | ||
@book.update(:ranking => 0) | ||
if @book.save | ||
redirect_to book_path(@book) | ||
else | ||
render "new" | ||
end | ||
end | ||
|
||
def show | ||
id = params[:id] | ||
@book = Book.find(id) | ||
end | ||
|
||
def edit | ||
@title = "Edit a book" | ||
id = params[:id] | ||
@book = Book.find(id) | ||
@action = :update | ||
end | ||
|
||
def update | ||
@value = params[:ranking] | ||
id = params[:id] | ||
@book = Book.find(id) | ||
@book.attributes = book_params[:book] | ||
if @book.save | ||
redirect_to book_path(params[:id]) | ||
else | ||
@title = "Edit a book" | ||
@action = :update | ||
render :edit | ||
end | ||
end | ||
|
||
|
||
def destroy | ||
Book.destroy(params[:id]) | ||
redirect_to books_path | ||
end | ||
|
||
def upvote | ||
id = params[:id] | ||
book = Book.find(id) | ||
r = book.ranking | ||
r += 1 | ||
book.update(ranking: r) | ||
redirect_to :back | ||
end | ||
|
||
private | ||
|
||
def book_params | ||
params.permit(book:[:author, :title, :ranking, :description]) | ||
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,76 @@ | ||
class MoviesController < ApplicationController | ||
|
||
def home | ||
@movies = Movie.all.order(:ranking).reverse.take(10) | ||
@books = Book.all.order(:ranking).reverse.take(10) | ||
@albums = Album.all.order(:ranking).reverse.take(10) | ||
end | ||
|
||
def index | ||
@movies = Movie.all | ||
end | ||
|
||
def new | ||
@action = :create | ||
@movie = Movie.new | ||
end | ||
|
||
def create | ||
@title = "Add a movie" | ||
@movie = Movie.new(movie_params[:movie]) | ||
@movie.update(:ranking => 0) | ||
if @movie.save | ||
redirect_to movie_path(@movie) | ||
else | ||
render :new | ||
end | ||
end | ||
|
||
def show | ||
id = params[:id] | ||
@movie = Movie.find(id) | ||
end | ||
|
||
def edit | ||
@title = "Edit a movie" | ||
id = params[:id] | ||
@movie = Movie.find(id) | ||
@action = :update | ||
end | ||
|
||
## use attributes, save it to a local variable (its a hash) | ||
# then use .save boolean to test against | ||
def update | ||
@value = params[:ranking] | ||
id = params[:id] | ||
@movie = Movie.find(id) | ||
@movie.attributes = movie_params[:movie] | ||
if @movie.save | ||
redirect_to movie_path(params[:id]) | ||
else | ||
@title = "Edit a movie" | ||
@action = :update | ||
render :edit | ||
end | ||
end | ||
|
||
def destroy | ||
Movie.destroy(params[:id]) | ||
redirect_to movies_path | ||
end | ||
|
||
def upvote | ||
id = params[:id] | ||
movie = Movie.find(id) | ||
r = movie.ranking | ||
r += 1 | ||
movie.update(ranking: r) | ||
redirect_to :back | ||
end | ||
|
||
private | ||
|
||
def movie_params | ||
params.permit(movie: [:title, :director, :ranking, :description]) | ||
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 AlbumsHelper | ||
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 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,5 @@ | ||
class Album < ActiveRecord::Base | ||
|
||
validates :title, presence: true | ||
|
||
end |
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.
Your initial setup of individual controllers for book, movie and albums are very clean. Nice.