-
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
Media Ranker Project #49
base: th/master
Are you sure you want to change the base?
Changes from all commits
dbd1e17
f2135a6
ab36e37
61e4358
61e33ff
aa71225
72475cf
998cc26
b11a522
da7e1e1
babed91
e68f880
c64fc6a
93dfe18
9beadeb
993546e
f079caa
0a98e48
aad7dbb
4371636
e66d3a9
3d33ca3
e22e549
6de9d81
563a06d
166ea54
4050037
04ecc23
54cbacc
fedf322
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 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/ |
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 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,3 @@ | ||
// Place all the styles related to the welcome 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,63 @@ | ||
class AlbumsController < ApplicationController | ||
|
||
def get_album | ||
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. I love your |
||
@album = Album.find(params[:id]) | ||
end | ||
|
||
def index | ||
@albums = Album.all | ||
end | ||
|
||
def new | ||
@album = Album.new | ||
end | ||
|
||
def edit | ||
get_album | ||
end | ||
|
||
def show | ||
get_album | ||
end | ||
|
||
def update | ||
if params[:class] == "upvote" | ||
get_album | ||
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. Minor refactor, you could bump |
||
rank = @album[:rank] + 1 | ||
@album.update(:rank => rank) | ||
render "show" | ||
elsif params[:class] == "upvote_i" | ||
get_album | ||
rank = @album[:rank] + 1 | ||
@album.update(:rank => rank) | ||
redirect_to albums_path | ||
else | ||
get_album | ||
@album.update(album_params[:album]) | ||
redirect_to album_path | ||
end | ||
end | ||
|
||
|
||
def create | ||
@album = Album.new(album_params[:album]) | ||
@album.update(:rank => 0) | ||
if @album.save | ||
redirect_to albums_path | ||
else | ||
render "new" | ||
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 |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,62 @@ | ||
class BooksController < ApplicationController | ||
|
||
def get_book | ||
@book = Book.find(params[:id]) | ||
end | ||
|
||
def index | ||
@books = Book.all | ||
end | ||
|
||
def new | ||
@book = Book.new | ||
end | ||
|
||
def edit | ||
get_book | ||
end | ||
|
||
def show | ||
get_book | ||
end | ||
|
||
def update | ||
if params[:class] == "upvote" | ||
get_book | ||
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. same refactor here and in update movie as listed above in album |
||
rank = @book[:rank] + 1 | ||
@book.update(:rank => rank) | ||
render "show" | ||
elsif params[:class] == "upvote_i" | ||
get_book | ||
rank = @book[:rank] + 1 | ||
@book.update(:rank => rank) | ||
redirect_to books_path | ||
else | ||
get_book | ||
@book.update(book_params[:book]) | ||
redirect_to book_path | ||
end | ||
end | ||
|
||
def create | ||
@book = Book.new(book_params[:book]) | ||
@book.update(:rank => 0) | ||
if @book.save | ||
redirect_to books_path | ||
else | ||
render "new" | ||
end | ||
end | ||
|
||
def destroy | ||
Book.destroy(params[:id]) | ||
redirect_to books_path | ||
end | ||
|
||
private | ||
|
||
def book_params | ||
params.permit(book: [:name, :author, :description, :rank]) | ||
end | ||
|
||
end |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,64 @@ | ||
class MoviesController < ApplicationController | ||
|
||
def get_movie | ||
@movie = Movie.find(params[:id]) | ||
end | ||
|
||
def index | ||
@movies = Movie.all | ||
end | ||
|
||
def new | ||
@movie = Movie.new | ||
end | ||
|
||
def show | ||
get_movie | ||
end | ||
|
||
def edit | ||
get_movie | ||
end | ||
|
||
def update | ||
if params[:class] == "upvote" | ||
get_movie | ||
rank = @movie[:rank] + 1 | ||
@movie.update(:rank => rank) | ||
render "show" | ||
elsif params[:class] == "upvote_i" | ||
get_movie | ||
rank = @movie[:rank] + 1 | ||
@movie.update(:rank => rank) | ||
redirect_to movies_path | ||
else | ||
get_movie | ||
if @movie.update(movie_params[:movie]) | ||
redirect_to movie_path | ||
else | ||
render "edit" | ||
end | ||
end | ||
end | ||
|
||
def create | ||
@movie = Movie.new(movie_params[:movie]) | ||
@movie.update(:rank => 0) | ||
if @movie.save | ||
redirect_to movies_path | ||
else | ||
render "new" | ||
end | ||
end | ||
|
||
def destroy | ||
Movie.destroy(params[:id]) | ||
redirect_to movies_path | ||
end | ||
|
||
private | ||
|
||
def movie_params | ||
params.permit(movie: [:name, :director, :description, :rank]) | ||
end | ||
end |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
class WelcomeController < ApplicationController | ||
|
||
def index | ||
@movies = Movie.all | ||
@albums = Album.all | ||
@books = Book.all | ||
end | ||
|
||
end |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
module AlbumsHelper | ||
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.
When using images it is safer to download the image and reference to it's folder location rather than rely on a 3rd party website. The image may get taken down or moved by the owner of the site or even worse could be swapped out for something unsavory.