-
Notifications
You must be signed in to change notification settings - Fork 21
Final Media Ranker PR #33
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
base: cas/master
Are you sure you want to change the base?
Changes from all commits
ce25711
5810d30
467f9b2
f200a8e
b09f693
e33df21
6f369e8
6318ea6
90e1347
91c6f4d
da67f94
db8415b
e98a8e6
e58a5fa
f936a2e
e7d8bdf
ebcdcfa
c6f643a
ac06ce4
6d5d18a
89f67a6
ce8bc89
859d7ce
4e0073f
346dd21
c047b37
a48c402
ce653e1
58db5fd
798f340
05d1ecf
afb713c
cf6c1a8
c055237
30640c8
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 |
|---|---|---|
|
|
@@ -10,6 +10,30 @@ | |
| * defined in the other CSS/SCSS files in this directory. It is generally better to create a new | ||
| * file per style scope. | ||
| * | ||
| *= require_tree . | ||
| *= require_self | ||
| */ | ||
|
|
||
| // "bootstrap-sprockets" must be imported before "bootstrap" and "bootstrap/variables" | ||
| @import "bootstrap-sprockets"; | ||
| @import "bootstrap"; | ||
|
|
||
| .page-header { | ||
| background: url(/assets/owl.jpg); | ||
| background-repeat: no-repeat; | ||
| padding-bottom: 9px; | ||
| margin: 40px 0 20px; | ||
|
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. Try to keep indentation consistent |
||
| border-bottom: 1px solid #eee; | ||
| } | ||
|
|
||
| .page-header h1 { | ||
| margin-left: 150px; | ||
| } | ||
|
|
||
| a { | ||
| color: #428bca; | ||
| } | ||
|
|
||
| .btn-primary { | ||
| margin-top: 10px; | ||
| margin-right: 10px; | ||
| 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 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,52 @@ | ||
| class AlbumsController < ApplicationController | ||
| before_action only: [:show, :edit, :update, :upvote] { @album = Album.find(params[:id]) } | ||
|
|
||
| def index | ||
| @albums = Album.order(rank: :desc) | ||
| end | ||
|
|
||
| def show | ||
| end | ||
|
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. This is just a style guide (have you covered this?) thing: |
||
|
|
||
| def new | ||
| @album = Album.new | ||
| end | ||
|
|
||
| def create | ||
| @album = Album.create(album_params[:album]) | ||
| if @album.save | ||
| redirect_to album_path(@album) | ||
| else | ||
| render "new" | ||
| end | ||
| end | ||
|
|
||
| def edit | ||
| end | ||
|
|
||
| def update | ||
| @album.update(album_params[:album]) | ||
| if @album.save | ||
| redirect_to album_path(@album) | ||
| else | ||
| render "edit" | ||
| end | ||
| end | ||
|
|
||
| def destroy | ||
| Album.destroy(params[:id]) | ||
| redirect_to albums_path | ||
| end | ||
|
|
||
| def upvote | ||
| @album.rank += 1 | ||
| @album.save | ||
| redirect_to album_path(@album.id) | ||
| end | ||
|
|
||
| private | ||
|
|
||
| def album_params | ||
|
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 really like that you made this method private |
||
| params.permit(album: [:name, :artist, :description, :rank]) | ||
| end | ||
| end | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,54 @@ | ||
| 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. I like that your controllers are really clean and easy to read |
||
| before_action only: [:show, :edit, :update, :upvote] { @book = Book.find(params[:id])} | ||
|
|
||
| def index | ||
| @books = Book.order(rank: :desc) | ||
| end | ||
|
|
||
| def show | ||
| end | ||
|
|
||
| def new | ||
| @book = Book.new | ||
| end | ||
|
|
||
| def create | ||
| @book = Book.create(book_params[:book]) | ||
|
|
||
| if @book.save | ||
| redirect_to book_path(@book) | ||
| else | ||
| render "new" | ||
| end | ||
| end | ||
|
|
||
| def edit | ||
| end | ||
|
|
||
| def update | ||
| @book.update(book_params[:book]) | ||
| if @book.save | ||
| redirect_to book_path(@book) | ||
| else | ||
| render "edit" | ||
| end | ||
| end | ||
|
|
||
| def destroy | ||
| Book.destroy(params[:id]) | ||
| redirect_to books_path | ||
| end | ||
|
|
||
| def upvote | ||
| @book = Book.find(params[:id]) | ||
| @book.rank += 1 | ||
| @book.save | ||
| redirect_to book_path(@book) | ||
| 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,51 @@ | ||
| class MoviesController < ApplicationController | ||
| before_action only: [:show, :edit, :update, :upvote] { @movie = Movie.find(params[:id]) } | ||
| def index | ||
| @movies = Movie.order(rank: :desc) | ||
| end | ||
|
|
||
| def show | ||
| end | ||
|
|
||
| def new | ||
| @movie = Movie.new | ||
| end | ||
|
|
||
| def create | ||
| @movie = Movie.create(movie_params[:movie]) | ||
| if @movie.save | ||
| redirect_to movie_path(@movie) | ||
| else | ||
| render "new" | ||
| end | ||
| end | ||
|
|
||
| def edit | ||
| end | ||
|
|
||
| def update | ||
| @movie.update(movie_params[:movie]) | ||
| if @movie.save | ||
| redirect_to movie_path(@movie) | ||
| else | ||
| render "edit" | ||
| end | ||
| end | ||
|
|
||
| def destroy | ||
| Movie.destroy(params[:id]) | ||
| redirect_to movies_path | ||
| end | ||
|
|
||
| def upvote | ||
| @movie.rank += 1 | ||
| @movie.save | ||
| redirect_to movie_path(@movie) | ||
| 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,7 @@ | ||
| class WelcomeController < ApplicationController | ||
| def index | ||
| @movies = Movie.order(rank: :desc).limit(10) | ||
| @books = Book.order(rank: :desc).limit(10) | ||
| @albums = Album.order(rank: :desc).limit(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. Have you discovered/learned about scopes yet? This would be good opportunity to check them out. Also recommend using a constant for the |
||
| end | ||
| end | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,2 @@ | ||
| module AlbumsHelper | ||
| end |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,2 @@ | ||
| module BooksHelper | ||
| end |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,2 @@ | ||
| module MoviesHelper | ||
| end |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,2 @@ | ||
| module WelcomeHelper | ||
| end |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,3 @@ | ||
| class Album < ActiveRecord::Base | ||
| validates :name, presence: :true | ||
| end |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,3 @@ | ||
| class Book < ActiveRecord::Base | ||
| validates :name, presence: :true | ||
| end |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,3 @@ | ||
| class Movie < ActiveRecord::Base | ||
| validates :name, presence: :true | ||
| end |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,10 @@ | ||
| <%= render partial: "application/edit", | ||
| locals: { | ||
| media: @album, | ||
| title: "Album", | ||
| singular_name: "album", | ||
| plur_name: "albums", | ||
| maker: "artist", | ||
| created_by: "Recorded by:", | ||
| } | ||
| %> |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,9 @@ | ||
| <%= render partial: "application/index", | ||
| locals: { | ||
| media: @albums, | ||
| title: "Album", | ||
| singular_name: "album", | ||
| plur_name: "albums", | ||
| created_by: "Recorded by:", | ||
| } | ||
| %> |
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.
Recommend you add
coverageto your .gitignore if you're going to use 'simplecov'