Skip to content
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

Open
wants to merge 45 commits into
base: riley/master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
45 commits
Select commit Hold shift + click to select a range
8e027b3
generated models
rileslovesyall Nov 30, 2015
4d43c35
CRUD views, routes and controller created
rileslovesyall Nov 30, 2015
75082cb
home controller and route added
rileslovesyall Nov 30, 2015
34bfd4a
added set_book action to DRY book controller code
rileslovesyall Nov 30, 2015
e2fdfc3
added CRUD actions to movie controller
rileslovesyall Nov 30, 2015
e41d6c1
CRUD actions added to albums
rileslovesyall Nov 30, 2015
1db3e8d
seeds written
rileslovesyall Nov 30, 2015
d3bed59
album model file added, set_book fixed
rileslovesyall Nov 30, 2015
4c942ba
Top items on home page code functioning
rileslovesyall Nov 30, 2015
845fc19
Added nav bar to top of layout with link back to main page
rileslovesyall Nov 30, 2015
2920d10
Skeleton of home page complete. Needs CSS for sure.
rileslovesyall Nov 30, 2015
a4a3c56
added the links to each model index pge on home page"
rileslovesyall Nov 30, 2015
24bd905
minor changes to front page to make it match better
rileslovesyall Nov 30, 2015
6ccda27
added name validations and rspec-rails gem
rileslovesyall Dec 1, 2015
24a95c8
added spec files for models and controllers
rileslovesyall Dec 1, 2015
be5cada
added require rails helper to spec files
rileslovesyall Dec 1, 2015
a8fb4b3
added show partial
rileslovesyall Dec 1, 2015
9b8906b
rspec tests added for all controllers' indexes
rileslovesyall Dec 1, 2015
6a49675
added skeleton rspec for models
rileslovesyall Dec 1, 2015
0730535
all book specs passing
rileslovesyall Dec 1, 2015
33c96a5
Added tests for movie controller:
rileslovesyall Dec 1, 2015
f822821
basic specs added for albums
rileslovesyall Dec 1, 2015
9613bd5
added simplecov
rileslovesyall Dec 1, 2015
35dcac0
update spec written and passing for album
rileslovesyall Dec 1, 2015
6834d39
model validation tests written
rileslovesyall Dec 1, 2015
31ef940
update test passing
rileslovesyall Dec 1, 2015
54f6a86
fixed controllers and patch methods now running
rileslovesyall Dec 1, 2015
358dbf8
added a redirect if update is in error
rileslovesyall Dec 1, 2015
f7215d6
added update validation test to all controllers
rileslovesyall Dec 1, 2015
a0b4d3a
added spec for new action
rileslovesyall Dec 1, 2015
5c0bde7
fixed upvote to use patch thank the good ord that took forever
rileslovesyall Dec 2, 2015
6924fbb
test written and passing for upvote
rileslovesyall Dec 2, 2015
2bd46be
added uvote test to all controller specs
rileslovesyall Dec 2, 2015
b27bc88
changed books to book in requred params
rileslovesyall Dec 2, 2015
68a8ec3
added edit link to show page
rileslovesyall Dec 2, 2015
cb1dce2
delete method being tested and passing in all controllers, 100% cover…
rileslovesyall Dec 2, 2015
3dbdfd1
I forgot to commit for a while, but msotly i've been bootstrapping i …
rileslovesyall Dec 2, 2015
27d26b3
home page looks mostly right
rileslovesyall Dec 2, 2015
9c69688
nav bar header looks right fiiiinally
rileslovesyall Dec 2, 2015
ebb0e44
bootstrapping done, sites look similar
rileslovesyall Dec 2, 2015
4029d94
made sure that filling in a form without a name works properly
rileslovesyall Dec 2, 2015
3a96c76
added shared examples for models
rileslovesyall Dec 3, 2015
8b02dd0
fixed update validation test
rileslovesyall Dec 3, 2015
780784c
got shared specs working for movies and albums;
rileslovesyall Dec 3, 2015
8fdcaa0
shared examples working for all
rileslovesyall Dec 3, 2015
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions .rspec
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
--color
--require spec_helper
6 changes: 6 additions & 0 deletions Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@ source 'https://rubygems.org'
gem 'rails', '4.2.5'
# Use sqlite3 as the database for Active Record
gem 'sqlite3'
# Use Bootstrap for styling
gem 'bootstrap-sass', '~> 3.3.6'
# Use SCSS for stylesheets
gem 'sass-rails', '~> 5.0'
# Use Uglifier as compressor for JavaScript assets
Expand Down Expand Up @@ -39,13 +41,17 @@ end
group :development, :test do
# Call 'byebug' anywhere in the code to stop execution and get a debugger console
gem 'byebug'
gem 'rspec-rails'
gem 'simplecov'
gem 'pry'
end

group :development do
# Access an IRB console on exception pages or by using <%= console %> in views
gem 'web-console', '~> 2.0'
gem 'better_errors'
gem 'binding_of_caller'
gem 'rails-erd'

# Spring speeds up development by keeping your application running in the background. Read more: https://github.com/rails/spring
gem 'spring'
Expand Down
48 changes: 48 additions & 0 deletions Gemfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -37,14 +37,21 @@ GEM
thread_safe (~> 0.3, >= 0.3.4)
tzinfo (~> 1.1)
arel (6.0.3)
autoprefixer-rails (6.1.2)
execjs
json
better_errors (2.1.1)
coderay (>= 1.0.0)
erubis (>= 2.6.6)
rack (>= 0.9.0)
binding_of_caller (0.7.2)
debug_inspector (>= 0.0.1)
bootstrap-sass (3.3.6)
autoprefixer-rails (>= 5.2.1)
sass (>= 3.3.4)
builder (3.2.2)
byebug (8.2.1)
choice (0.2.0)
coderay (1.1.0)
coffee-rails (4.1.0)
coffee-script (>= 2.2.0)
Expand All @@ -54,6 +61,8 @@ GEM
execjs
coffee-script-source (1.10.0)
debug_inspector (0.0.2)
diff-lcs (1.2.5)
docile (1.1.5)
erubis (2.7.0)
execjs (2.6.0)
globalid (0.3.6)
Expand All @@ -71,13 +80,18 @@ GEM
nokogiri (>= 1.5.9)
mail (2.6.3)
mime-types (>= 1.16, < 3)
method_source (0.8.2)
mime-types (2.99)
mini_portile2 (2.0.0)
minitest (5.8.3)
multi_json (1.11.2)
nokogiri (1.6.7)
mini_portile2 (~> 2.0.0.rc2)
pg (0.18.4)
pry (0.10.3)
coderay (~> 1.1.0)
method_source (~> 0.8.1)
slop (~> 3.4)
rack (1.6.4)
rack-test (0.6.3)
rack (>= 1.0)
Expand All @@ -98,6 +112,11 @@ GEM
activesupport (>= 4.2.0.beta, < 5.0)
nokogiri (~> 1.6.0)
rails-deprecated_sanitizer (>= 1.0.1)
rails-erd (1.4.4)
activerecord (>= 3.2)
activesupport (>= 3.2)
choice (~> 0.2.0)
ruby-graphviz (~> 1.2)
rails-html-sanitizer (1.0.2)
loofah (~> 2.0)
railties (4.2.5)
Expand All @@ -107,6 +126,24 @@ GEM
thor (>= 0.18.1, < 2.0)
rake (10.4.2)
rdoc (4.2.0)
rspec-core (3.4.1)
rspec-support (~> 3.4.0)
rspec-expectations (3.4.0)
diff-lcs (>= 1.2.0, < 2.0)
rspec-support (~> 3.4.0)
rspec-mocks (3.4.0)
diff-lcs (>= 1.2.0, < 2.0)
rspec-support (~> 3.4.0)
rspec-rails (3.4.0)
actionpack (>= 3.0, < 4.3)
activesupport (>= 3.0, < 4.3)
railties (>= 3.0, < 4.3)
rspec-core (~> 3.4.0)
rspec-expectations (~> 3.4.0)
rspec-mocks (~> 3.4.0)
rspec-support (~> 3.4.0)
rspec-support (3.4.1)
ruby-graphviz (1.2.2)
sass (3.4.19)
sass-rails (5.0.4)
railties (>= 4.0.0, < 5.0)
Expand All @@ -117,6 +154,12 @@ GEM
sdoc (0.4.1)
json (~> 1.7, >= 1.7.7)
rdoc (~> 4.0)
simplecov (0.11.0)
docile (~> 1.1.0)
json (~> 1.8)
simplecov-html (~> 0.10.0)
simplecov-html (0.10.0)
slop (3.6.0)
spring (1.5.0)
sprockets (3.4.1)
rack (> 1, < 3)
Expand Down Expand Up @@ -147,14 +190,19 @@ PLATFORMS
DEPENDENCIES
better_errors
binding_of_caller
bootstrap-sass (~> 3.3.6)
byebug
coffee-rails (~> 4.1.0)
jbuilder (~> 2.0)
jquery-rails
pg
pry
rails (= 4.2.5)
rails-erd
rspec-rails
sass-rails (~> 5.0)
sdoc (~> 0.4.0)
simplecov
spring
sqlite3
turbolinks
Expand Down
Binary file added app/assets/images/owl.jpeg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added app/assets/images/owl.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
3 changes: 3 additions & 0 deletions app/assets/javascripts/album.coffee
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/
3 changes: 3 additions & 0 deletions app/assets/javascripts/albums.coffee
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/
1 change: 1 addition & 0 deletions app/assets/javascripts/application.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
// about supported directives.
//
//= require jquery
//= require bootstrap-sprockets
//= require jquery_ujs
//= require turbolinks
//= require_tree .
3 changes: 3 additions & 0 deletions app/assets/javascripts/books.coffee
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/
3 changes: 3 additions & 0 deletions app/assets/javascripts/home.coffee
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/
3 changes: 3 additions & 0 deletions app/assets/javascripts/movies.coffee
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/
3 changes: 3 additions & 0 deletions app/assets/stylesheets/album.scss
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/
3 changes: 3 additions & 0 deletions app/assets/stylesheets/albums.scss
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/
15 changes: 0 additions & 15 deletions app/assets/stylesheets/application.css

This file was deleted.

34 changes: 34 additions & 0 deletions app/assets/stylesheets/application.scss
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;
}
3 changes: 3 additions & 0 deletions app/assets/stylesheets/books.scss
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/
3 changes: 3 additions & 0 deletions app/assets/stylesheets/home.scss
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/
3 changes: 3 additions & 0 deletions app/assets/stylesheets/movies.scss
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/
57 changes: 57 additions & 0 deletions app/controllers/albums_controller.rb
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]

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]


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

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Another way you can write an empty body method is def edit; end

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)

Choose a reason for hiding this comment

The 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
58 changes: 58 additions & 0 deletions app/controllers/books_controller.rb
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
11 changes: 11 additions & 0 deletions app/controllers/home_controller.rb
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

Choose a reason for hiding this comment

The 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
Loading