Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
39 commits
Select commit Hold shift + click to select a range
cb7188f
generated controllers for books, movies, and albums. All views were a…
morrime Oct 11, 2016
4a369cf
switched location of better_errors gem from group :development :test,…
morrime Oct 11, 2016
53590b3
fixed routes for movies, books, and albums, used resources to clean i…
morrime Oct 11, 2016
42c8404
populated arguments in all 3 controllers. Still need params
morrime Oct 11, 2016
cf4bc6a
generated models with data fields and types, raked the migration
morrime Oct 11, 2016
ebfe465
added params for movies, books, and albums. not sure yet if I should …
morrime Oct 11, 2016
2aafb90
fixed indentation in controllers
morrime Oct 11, 2016
a095552
created validations for movie, book, and album. not sure if rank shou…
morrime Oct 11, 2016
24f8c1e
put html skeleton, header, and footer stuff in application.html.erb
morrime Oct 11, 2016
8a923a1
created form files
morrime Oct 11, 2016
a48c9ac
populated forms
morrime Oct 11, 2016
9b8a94e
rendered partials in the 'new' files
morrime Oct 11, 2016
0a022a2
rendered partials in the 'edit' files
morrime Oct 11, 2016
a0f486d
populated show pages, still need upvote functionality/path, and view …
morrime Oct 11, 2016
16bac06
cleaned up views (deleted unnecessary ones), also populated index vie…
morrime Oct 11, 2016
61aeace
fixed indentation in views show & index pages
morrime Oct 11, 2016
bad7d3f
fixed tables and paths
morrime Oct 11, 2016
7c37cb6
working on upvote functionality. totally broken, but trying to make b…
morrime Oct 12, 2016
6f93832
UPVOTE FUNCTIONALTY: raked migration to change rank default value fro…
morrime Oct 12, 2016
e747449
created root route and home view under books controller
morrime Oct 12, 2016
4163a4d
upvote working on index for each, but not on show - need to fix. Swit…
morrime Oct 14, 2016
65fb1c5
added link to landing page on all media index pages
morrime Oct 14, 2016
00e588c
created upvote button on media show pages, fixed delete link on album…
morrime Oct 14, 2016
b5466d1
added @books_by_rank to index action for each media controller, fixed…
morrime Oct 14, 2016
5eb659a
deleted 'yolo' from home page
morrime Oct 14, 2016
0d6b0c3
added owl.jpg to images, changed header in application.html.erb to in…
morrime Oct 14, 2016
6ba25cc
deleted extraneous '>'
morrime Oct 14, 2016
ad8a494
setup for model testing
morrime Oct 16, 2016
82ccbff
populated yaml files
morrime Oct 16, 2016
1855864
tweaked yaml files to have missing data so negative tests would pass,…
morrime Oct 16, 2016
17e1f39
added assertions for rank for all 3 media types
morrime Oct 16, 2016
a94fb48
wrote controller tests for index and new for each media type, and ind…
morrime Oct 17, 2016
1db394e
added test to each media type controller, tests it won't add an inval…
morrime Oct 17, 2016
28c1c39
added tests that show will show the correct media item
morrime Oct 17, 2016
83d3e46
added tests for all 3 media types for adding a new item
morrime Oct 17, 2016
f8d46c0
Added tests for update & edit
morrime Oct 17, 2016
e17ce46
added destroy controller tests for each, had to update controller met…
morrime Oct 17, 2016
6cb1d33
tried to do test for upvote. It passes, but isn't working correctly. …
morrime Oct 17, 2016
d28faf5
Changed upvote tests. Getting Error 'undefined method upvote'. If lin…
morrime Oct 17, 2016
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
6 changes: 5 additions & 1 deletion Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -35,12 +35,16 @@ gem 'sdoc', '~> 0.4.0', group: :doc
group :development, :test do
# Call 'byebug' anywhere in the code to stop execution and get a debugger console
gem 'byebug'
gem 'better_errors'
end

group :test do
gem 'minitest-reporters'
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'

# Spring speeds up development by keeping your application running in the background. Read more: https://github.com/rails/spring
gem 'spring'
Expand Down
14 changes: 14 additions & 0 deletions Gemfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -36,11 +36,17 @@ GEM
minitest (~> 5.1)
thread_safe (~> 0.3, >= 0.3.4)
tzinfo (~> 1.1)
ansi (1.5.0)
arel (6.0.3)
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)
builder (3.2.2)
byebug (9.0.6)
coderay (1.1.1)
coffee-rails (4.1.1)
coffee-script (>= 2.2.0)
railties (>= 4.0.0, < 5.1.x)
Expand Down Expand Up @@ -72,6 +78,11 @@ GEM
mime-types-data (3.2016.0521)
mini_portile2 (2.1.0)
minitest (5.9.1)
minitest-reporters (1.1.11)
ansi
builder
minitest (>= 5.0)
ruby-progressbar
multi_json (1.12.1)
nokogiri (1.6.8.1)
mini_portile2 (~> 2.1.0)
Expand Down Expand Up @@ -105,6 +116,7 @@ GEM
rake (11.3.0)
rdoc (4.2.2)
json (~> 1.4)
ruby-progressbar (1.8.1)
sass (3.4.22)
sass-rails (5.0.6)
railties (>= 4.0.0, < 6)
Expand Down Expand Up @@ -145,10 +157,12 @@ PLATFORMS
ruby

DEPENDENCIES
better_errors
byebug
coffee-rails (~> 4.1.0)
jbuilder (~> 2.0)
jquery-rails
minitest-reporters
rails (= 4.2.7)
sass-rails (~> 5.0)
sdoc (~> 0.4.0)
Expand Down
Binary file added app/assets/images/owl.jpg
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/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/
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/homes.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/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/
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/homes.scss
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
// Place all the styles related to the Homes 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/
59 changes: 59 additions & 0 deletions app/controllers/albums_controller.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
class AlbumsController < ApplicationController
def index
@albums = Album.all
@albums_by_rank = Album.order(:rank).reverse

end

def new
@album = Album.new
end

def create
@album = Album.new(album_params)
if @album.save
redirect_to albums_path
else
render :new
end
end

def edit
@album = Album.find(params[:id])
end

def update
@album = Album.find(params[:id])
if @album.update(album_params)
redirect_to albums_path
else
render :edit
end

end

def destroy
@album = Album.find(params[:id])
@album.destroy
redirect_to album_path
end

def show
@album = Album.find(params[:id])
end

def upvote
@album = Album.find(params[:id])
@album.rank += 1
@album.save
redirect_to :back
end

private

def album_params
params.require(:album).permit(:name, :artist, :description) #do i want :rank ?
end


end
57 changes: 57 additions & 0 deletions app/controllers/books_controller.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
class BooksController < ApplicationController
def index
@books = Book.all
@books_by_rank = Book.order(:rank).reverse
end

def new
@book = Book.new
end

def create
@book = Book.new(book_params)
if @book.save
redirect_to books_path
else
render :new
end
end

def edit
@book = Book.find(params[:id])
end

def update
@book = Book.find(params[:id])
if @book.update(book_params)
redirect_to books_path
else
render :edit
end
end

def destroy
@book = Book.find(params[:id])
@book.destroy
redirect_to book_path
end

def show
@book = Book.find(params[:id])
end

def upvote
@book = Book.find(params[:id])
@book.rank += 1
@book.save
redirect_to :back
end

private

def book_params
params.require(:book).permit(:name, :author, :description) #do i want :rank ?
end


end
7 changes: 7 additions & 0 deletions app/controllers/homes_controller.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
class HomesController < ApplicationController
def index
@movies_by_rank = Movie.order(:rank).reverse
@books_by_rank = Book.order(:rank).reverse
@albums_by_rank = Album.order(:rank).reverse
end
end
60 changes: 60 additions & 0 deletions app/controllers/movies_controller.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
class MoviesController < ApplicationController
def index
@movies = Movie.all
@movies_by_rank = Movie.order(:rank).reverse

end

def new
@movie = Movie.new
end

def create
@movie = Movie.new(movie_params)
if @movie.save
redirect_to movies_path
else
render :new
end
end

def edit
@movie = Movie.find(params[:id])
end

def update
@movie = Movie.find(params[:id])
if @movie.update(movie_params)
redirect_to movies_path
else
render :edit
end

end

def destroy
@movie = Movie.find(params[:id])
@movie.destroy
redirect_to movie_path
end

def show
@movie = Movie.find(params[:id])
end

def upvote
@movie = Movie.find(params[:id])
@movie.rank += 1
@movie.save

redirect_to :back
end


private

def movie_params
params.require(:movie).permit(:name, :director, :description) #do i want :rank ?
end

end
2 changes: 2 additions & 0 deletions app/helpers/albums_helper.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
module AlbumsHelper
end
2 changes: 2 additions & 0 deletions app/helpers/books_helper.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
module BooksHelper
end
2 changes: 2 additions & 0 deletions app/helpers/homes_helper.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
module HomesHelper
end
2 changes: 2 additions & 0 deletions app/helpers/movies_helper.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
module MoviesHelper
end
6 changes: 6 additions & 0 deletions app/models/album.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
class Album < ActiveRecord::Base

validates :name, presence: true
validates :artist, presence: true

end
6 changes: 6 additions & 0 deletions app/models/book.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
class Book < ActiveRecord::Base

validates :name, presence: true
validates :author, presence: true

end
6 changes: 6 additions & 0 deletions app/models/movie.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
class Movie < ActiveRecord::Base

validates :name, presence: true
validates :director, presence: true

end
20 changes: 20 additions & 0 deletions app/views/albums/_form.html.erb
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
<% if @album.errors.any? %>
<ul>
<% @album.errors.each do |column, message| %>
<li>
<%= column %>
<%= message %>
</li>
<% end %>
</ul>
<% end %>

<%= form_for @album, method: action_name do |f| %>
<%= f.label :name %>
<%= f.text_field :name %>
<%= f.label :artist %>
<%= f.text_field :artist %>
<%= f.label :description %>
<%= f.text_field :description %>
<%= f.submit "Submit!" %>
<% end %>
1 change: 1 addition & 0 deletions app/views/albums/edit.html.erb
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
<%= render partial: "form", locals: {action_name: :patch} %>
17 changes: 17 additions & 0 deletions app/views/albums/index.html.erb
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
<table>
<tr>
<th>Ranking</th>
<th>Name</th>
<th>Upvote</th>
</tr>
<% @albums_by_rank.each do |album| %>
<tr>
<td><%= " #{album.rank}" %></td>
<td><%= link_to "#{album.name}", album_path(album.id)%></td>
<td><%= button_to "Upvote", upvote_album_path(album), method: :patch %></td>
</tr>
<% end %>
</table>

<h4><%= link_to "Add an Album", new_album_path %> <%= link_to "View All Media", homes_index_path%>
</h4>
1 change: 1 addition & 0 deletions app/views/albums/new.html.erb
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
<%= render partial: "form", locals: {action_name: :post} %>
25 changes: 25 additions & 0 deletions app/views/albums/show.html.erb
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
<h3><%= "#{@album.name} Recorded by: #{@album.artist}" %></h3>

<h4><%= "Ranked: #{@album.rank}" %></h4>
<p><%= "#{@album.description}" %></p>

<!-- UPVOTE -->
<td><%= button_to "Upvote", upvote_album_path(@album), method: :patch %></td>

<!-- EDIT -->

<%= link_to "Edit #{@album.name}", edit_album_path %>


<!-- DELETE -->

<%= link_to "DELETE", album_path(@album), method: :destroy,
data: {confirm: "Are you really, really sure?"}%></li>

<!-- VIEW ALL ALBUMS -->

<%= link_to "View All Albums", albums_path %>

<!-- VIEW ALL MEDIA -->

<%= link_to "View All Media", homes_index_path %>
Loading