-
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
Audrey's final MediaRanker #28
base: ald/master
Are you sure you want to change the base?
Changes from all commits
821d9b7
030cf4f
9cd2a63
865cc69
6adfe0a
5ef28c9
644245e
a39ae30
890c6b0
481daf3
1a6d662
b6f6a51
9a63984
a2f1e19
7044e70
8510d06
154f907
326f7ef
f0dfb7e
1d1aacf
f0f145f
ba9f55f
52af368
674ec6a
d82dbaa
d9ea6b0
a0c2335
5c2a967
b512930
1f0d599
665876c
6b92cf5
f5a6099
e3e7c48
e0f9603
c736eb7
876dbab
729dd69
d31d06c
38ac0ad
ea02238
347dd4e
9de29be
6f8221a
ccd4f0c
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/ |
This file was deleted.
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
// "bootstrap-sprockets" must be imported before "bootstrap" and "bootstrap/variables" | ||
@import "bootstrap-sprockets"; | ||
@import "bootstrap"; | ||
|
||
form .btn-primary { | ||
margin-bottom: 10px; | ||
} | ||
|
||
.page-header { | ||
background: url("bookowl.jpg"); | ||
background-repeat: no-repeat; | ||
} | ||
|
||
.page-header h1 { | ||
margin-left: 150px; | ||
} |
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,59 @@ | ||
class AlbumsController < ApplicationController | ||
|
||
def index | ||
@albums = Album.all | ||
end | ||
|
||
def upvote | ||
@album = Album.find(params[:id]) | ||
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. Because we're setting the |
||
@album.update_attribute(:ranking, @album.ranking + 1) | ||
redirect_to action: :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. We should use a route helper method for this, |
||
end | ||
|
||
def show | ||
@album = Album.find(params[:id]) | ||
end | ||
|
||
def new | ||
@album = Album.new | ||
end | ||
|
||
def create | ||
@album = Album.create(title: album_params[:album][:title], | ||
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. Because we're using the special "strong params" syntax to implement @album = Album.create(album_params[:album]) do |album|
album.ranking = 0
end That way, if we want to add more parameters to Album (and Movie or Book) we just need to add them into |
||
description: album_params[:album][:description], | ||
artist: album_params[:album][:artist], | ||
ranking: 0) | ||
if @album.save | ||
redirect_to album_path(@album.id) | ||
else | ||
render "new" | ||
end | ||
end | ||
|
||
def edit | ||
id = params[:id] | ||
@album = Album.find(id) | ||
end | ||
|
||
def update | ||
id = params[:id] | ||
@album = Album.find(id) | ||
if @album.update(album_params[:album]) | ||
redirect_to album_path(@album.id) | ||
else | ||
render "edit" | ||
end | ||
end | ||
|
||
def destroy | ||
id = params[:id] | ||
Album.destroy(id) | ||
redirect_to albums_path | ||
end | ||
|
||
private | ||
|
||
def album_params | ||
params.permit(album:[:title, :description, :ranking, :artist]) | ||
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 we change this line to: params.require(:album).permit(:title, :description, :ranking, :artist) ... we get slightly more security (params must have a sub-hash called |
||
end | ||
end |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,58 @@ | ||
class BooksController < ApplicationController | ||
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. Basically the same comments from |
||
def index | ||
@books = Book.all | ||
end | ||
|
||
def upvote | ||
@book = Book.find(params[:id]) | ||
@book.update_attribute(:ranking, @book.ranking + 1) | ||
redirect_to action: :show | ||
end | ||
|
||
def show | ||
@book = Book.find(params[:id]) | ||
end | ||
|
||
def new | ||
@book = Book.new | ||
end | ||
|
||
def create | ||
@book = Book.create(title: book_params[:book][:title], | ||
description: book_params[:book][:description], | ||
author: book_params[:book][:author], | ||
ranking: 0) | ||
if @book.save | ||
redirect_to book_path(@book.id) | ||
else | ||
render "new" | ||
end | ||
end | ||
|
||
def edit | ||
id = params[:id] | ||
@book = Book.find(id) | ||
end | ||
|
||
def update | ||
id = params[:id] | ||
@book = Book.find(id) | ||
if @book.update(book_params[:book]) | ||
redirect_to book_path(@book.id) | ||
else | ||
render "edit" | ||
end | ||
end | ||
|
||
def destroy | ||
id = params[:id] | ||
Book.destroy(id) | ||
redirect_to books_path | ||
end | ||
|
||
private | ||
|
||
def book_params | ||
params.permit(book:[:title, :description, :ranking, :author]) | ||
end | ||
end |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
class HomeController < ApplicationController | ||
before_action :get_movies | ||
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. Generally I like the use of |
||
before_action :get_books | ||
before_action :get_albums | ||
|
||
def index | ||
end | ||
|
||
private | ||
|
||
def get_movies | ||
@movies = Movie.all | ||
end | ||
|
||
def get_books | ||
@books = Book.all | ||
end | ||
|
||
def get_albums | ||
@albums = Album.all | ||
end | ||
end |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,58 @@ | ||
class MoviesController < ApplicationController | ||
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. Basically the same comments from |
||
def index | ||
@movies = Movie.all | ||
end | ||
|
||
def upvote | ||
@movie = Movie.find(params[:id]) | ||
@movie.update_attribute(:ranking, @movie.ranking + 1) | ||
redirect_to action: :show | ||
end | ||
|
||
def show | ||
@movie = Movie.find(params[:id]) | ||
end | ||
|
||
def new | ||
@movie = Movie.new | ||
end | ||
|
||
def create | ||
@movie = Movie.create(title: movie_params[:movie][:title], | ||
description: movie_params[:movie][:description], | ||
director: movie_params[:movie][:director], | ||
ranking: 0) | ||
if @movie.save | ||
redirect_to movie_path(@movie.id) | ||
else | ||
render "new" | ||
end | ||
end | ||
|
||
def edit | ||
id = params[:id] | ||
@movie = Movie.find(id) | ||
end | ||
|
||
def update | ||
id = params[:id] | ||
@movie = Movie.find(id) | ||
if @movie.update(movie_params[:movie]) | ||
redirect_to movie_path(@movie.id) | ||
else | ||
render "edit" | ||
end | ||
end | ||
|
||
def destroy | ||
id = params[:id] | ||
Movie.destroy(id) | ||
redirect_to movies_path | ||
end | ||
|
||
private | ||
|
||
def movie_params | ||
params.permit(movie:[:title, :description, :ranking, :director]) | ||
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.
It's not much of an issue to have this included in the project repo, although you could have put this
.rspec
file in your home directory and it would work for your local machine (across all projects).