-
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 PR #48
base: riley/master
Are you sure you want to change the base?
Final PR #48
Changes from all commits
8e027b3
4d43c35
75082cb
34bfd4a
e2fdfc3
e41d6c1
1db3e8d
d3bed59
4c942ba
845fc19
2920d10
a4a3c56
24bd905
6ccda27
24a95c8
be5cada
a8fb4b3
9b8906b
6a49675
0730535
33c96a5
f822821
9613bd5
35dcac0
6834d39
31ef940
54f6a86
358dbf8
f7215d6
a0b4d3a
5c0bde7
6924fbb
2bd46be
b27bc88
68a8ec3
cb1dce2
3dbdfd1
27d26b3
9c69688
ebb0e44
4029d94
3a96c76
8b02dd0
780784c
8fdcaa0
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
--color | ||
--require spec_helper |
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/ |
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/ |
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/ |
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/ |
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/ |
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/ |
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 was deleted.
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
|
||
// "bootstrap-sprockets" must be imported before "bootstrap" and "bootstrap/variables" | ||
@import "bootstrap-sprockets"; | ||
@import "bootstrap"; | ||
|
||
|
||
.page-header { | ||
background: url(http://media-ranker.herokuapp.com/assets/owl-5e51d9e0d49c787f2ebd143e32cbf41c.jpg); | ||
background-repeat: no-repeat; | ||
padding-bottom: 9px; | ||
margin: 40px 0 20px; | ||
border-bottom: 1px solid #eee; | ||
} | ||
|
||
.page-header h1 { | ||
margin-left: 150px; | ||
} | ||
|
||
a { | ||
color: #428bca; | ||
} | ||
|
||
h2 { | ||
margin-top: 20px; | ||
margin-bottom: 10px; | ||
font-family: inherit; | ||
font-weight: 500; | ||
line-height: 1.1; | ||
color: inherit; | ||
} | ||
|
||
.btn-primary { | ||
margin-bottom: 10px; | ||
} |
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/ |
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/ |
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/ |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,57 @@ | ||
class AlbumsController < ApplicationController | ||
before_action :set_album, only: [:edit, :show, :update, :destroy, :upvote] | ||
|
||
def new | ||
@media = Album.new | ||
end | ||
|
||
def create | ||
@album = Album.new(album_params) | ||
@album.votes = 0 | ||
if @album.save | ||
redirect_to album_path(@album) | ||
else | ||
@media = Album.new(album_params) | ||
render 'new' | ||
end | ||
end | ||
|
||
def edit | ||
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. Another way you can write an empty body method is |
||
end | ||
|
||
def update | ||
if @media.update(album_params) | ||
redirect_to album_path(@media) | ||
else | ||
redirect_to edit_album_path(@media) | ||
end | ||
end | ||
|
||
def index | ||
@media = Album.order(votes: :desc) | ||
end | ||
|
||
def show | ||
end | ||
|
||
def destroy | ||
@media.destroy | ||
redirect_to albums_path | ||
end | ||
|
||
def upvote | ||
@media.votes += 1 | ||
@media.save | ||
redirect_to :back | ||
end | ||
|
||
private | ||
|
||
def album_params | ||
return params.require(:album).permit(:name, :artist, :description) | ||
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. Since this is the last line of the method, ruby can have implicit returns; therefore you don't need the return word. It doesn't hurt any though to include it. |
||
end | ||
|
||
def set_album | ||
@media = Album.find(params[:id]) | ||
end | ||
end |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,58 @@ | ||
class BooksController < ApplicationController | ||
before_action :set_book, only: [:edit, :show, :update, :destroy, :upvote] | ||
|
||
def new | ||
@media = Book.new | ||
end | ||
|
||
def create | ||
@book = Book.new(book_params) | ||
@book.votes = 0 | ||
if @book.save | ||
redirect_to book_path(@book) | ||
else | ||
@book = Book.new(book_params) | ||
render 'new' | ||
end | ||
end | ||
|
||
def edit | ||
end | ||
|
||
def update | ||
if @media.update(book_params) | ||
redirect_to book_path(@media) | ||
else | ||
redirect_to edit_book_path(@media) | ||
end | ||
end | ||
|
||
def upvote | ||
@media.votes += 1 | ||
@media.save | ||
redirect_to :back | ||
end | ||
|
||
def index | ||
@media = Book.order(votes: :desc) | ||
end | ||
|
||
def show | ||
end | ||
|
||
def destroy | ||
@media.destroy | ||
redirect_to books_path | ||
end | ||
|
||
private | ||
|
||
def book_params | ||
return params.require(:book).permit(:name, :description, :author) | ||
end | ||
|
||
def set_book | ||
@media = Book.find(params[:id]) | ||
end | ||
|
||
end |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
class HomeController < ApplicationController | ||
|
||
def all_media | ||
# x is the number of items that will show in the 'top' display | ||
x = 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. Naming variables are hard! But I'd suggest renaming this to something other than a letter. Maybe 'top', 'top number', 'number_of_items' or something similar? "x" doesn't give you much info, hence the need for your comment. |
||
@top_movies = Movie.order(votes: :desc).limit(x) | ||
@top_books = Book.order(votes: :desc).limit(x) | ||
@top_albums = Album.order(votes: :desc).limit(x) | ||
end | ||
|
||
end |
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.
Nice use of a before_action. You could also do an except instead of only like so ->
before_action :set_album , except: [:index, :create, :new]