forked from AdaGold/media-ranker
-
Notifications
You must be signed in to change notification settings - Fork 21
Ricky final media ranker #27
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
Open
hougland
wants to merge
45
commits into
Ada-C4:ricky/master
Choose a base branch
from
hougland:ricky/master
base: ricky/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
45 commits
Select commit
Hold shift + click to select a range
0ad887e
generate movies, albums, books controllers
hougland f04d922
generate album, book, movie models
hougland fb74d4b
create seed data
hougland 17ac202
add contents to root view
hougland 0922379
add index for movies with table showing all movies
hougland e6f10ce
working on layout for movies, now starting on books
hougland cd61aa7
add destroy function
hougland 348c2c5
add upvote function for movies
hougland ef951c5
copy and pasting controller methods from movies to books and albums
hougland 038ee47
add partial for index pages for all resources
hougland 1b2d1b9
add views for other controllers
hougland e633fc5
copy and paste from movie show view to books and albums
hougland 2bc22e3
shortened how I was ordering media by ranking
hougland 45eefa1
create partial for show views
hougland 0370957
create partial form for new and edit for all controllers
hougland 4833112
add spec folder and blank necessary files
hougland 901ea3c
add default info to rails_helper and spec_helper, plus tests for mode…
hougland 40eb52f
add first tests for each controller, ensuring get index is successful
hougland d9d5862
add tests for get new form for all 3 controllers
hougland 3caf884
add get show tests and error keys for modles to include name
hougland da3d4f6
improve show test and add post create test for albums controller
hougland c20958d
add test for delete
hougland 92f012e
add test for upvote and update for album controller
hougland 1402b96
add test for unsuccessful create attempt wihtout name
hougland dfeac1b
add test for unsucessful update of albums
hougland d825093
tweaking tests
hougland 7045e6a
copy and paste tests for movie and book controllers, and run simplecov
hougland 2db2508
switch upvote from post to patch
hougland 2164ee8
switch buttons to links
hougland b5a556d
add one small test to upvote
hougland 38f0509
add bootstrap gem
hougland 34f454f
bootstrap format _index
hougland e9b58c5
bootstrap
hougland cddfea7
bootstrap
hougland 1895ed7
bootstrap
hougland dacc948
add http status tests
hougland c8be616
shared examples for models
hougland d9b7f3f
DRY up tests for for create and edit
hougland d1f61a7
DRY patch update tests
hougland 65a9d98
DRY upvote tests
hougland 56b2e4d
DRY up code
hougland 5f4e277
make header display correct text when editing or creating new media
hougland ee0b124
revise upvote paths
hougland ca2fa70
add to gitignore file
hougland f594ef8
add rspec tests
hougland 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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,61 @@ | ||
| class AlbumsController < ApplicationController | ||
| before_action :find_media, except: [:index, :new, :create] | ||
|
|
||
| def index | ||
| @media = Album.order(ranking: :desc) | ||
| end | ||
|
|
||
| def show | ||
| end | ||
|
|
||
| def new | ||
| @media = Album.new | ||
| end | ||
|
|
||
| def create | ||
| @media = Album.new(strong_params) | ||
| @media.ranking = 0 | ||
| if @media.save | ||
| render "show" | ||
| else | ||
| render "new" | ||
| end | ||
| end | ||
|
|
||
| def edit | ||
| end | ||
|
|
||
| def update | ||
| @media.attributes = strong_params | ||
| if @media.save | ||
| render "show" | ||
|
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. What are the trade-offs between using |
||
| else | ||
| render "edit" | ||
| end | ||
| end | ||
|
|
||
| def destroy | ||
| @media.destroy | ||
| redirect_to albums_path | ||
| end | ||
|
|
||
| def upvote | ||
| @media.ranking += 1 | ||
| @media.save | ||
| render "show" | ||
| end | ||
|
|
||
| private | ||
|
|
||
| def strong_params | ||
| params.require(:album).permit(:name, :artist, :description) | ||
| end | ||
|
|
||
| def find_media | ||
| if params[:id].nil? | ||
| @media = Album.find(params[:album_id]) | ||
| else | ||
| @media = Album.find(params[:id]) | ||
| end | ||
| end | ||
| end | ||
This file contains hidden or 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 hidden or 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,61 @@ | ||
| class BooksController < ApplicationController | ||
| before_action :find_media, except: [:index, :new, :create] | ||
|
|
||
| def index | ||
| @media = Book.order(ranking: :desc) | ||
| end | ||
|
|
||
| def show | ||
| end | ||
|
|
||
| def new | ||
| @media = Book.new | ||
| end | ||
|
|
||
| def create | ||
| @media = Book.new(strong_params) | ||
| @media.ranking = 0 | ||
| if @media.save | ||
| render "show" | ||
| else | ||
| render "new" | ||
| end | ||
| end | ||
|
|
||
| def edit | ||
| end | ||
|
|
||
| def update | ||
| @media.attributes = strong_params | ||
| if @media.save | ||
| render "show" | ||
| else | ||
| render "edit" | ||
| end | ||
| end | ||
|
|
||
| def destroy | ||
| @media.destroy | ||
| redirect_to books_path | ||
| end | ||
|
|
||
| def upvote | ||
| @media.ranking += 1 | ||
| @media.save | ||
| render "show" | ||
| end | ||
|
|
||
| private | ||
|
|
||
| def strong_params | ||
| params.require(:book).permit(:name, :author, :description) | ||
| end | ||
|
|
||
| def find_media | ||
| if params[:id].nil? | ||
| @media = Book.find(params[:book_id]) | ||
| else | ||
| @media = Book.find(params[:id]) | ||
| end | ||
| end | ||
| 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.
We could also do: