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

Media Ranker Project #49

Open
wants to merge 30 commits into
base: th/master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
30 commits
Select commit Hold shift + click to select a range
dbd1e17
made 3 models - book, movie, album
TammyHer Nov 30, 2015
f2135a6
created 4 new controller - 1 for welcome
TammyHer Nov 30, 2015
ab36e37
made home page
TammyHer Nov 30, 2015
61e4358
made routes and actions in the controllers
TammyHer Nov 30, 2015
61e33ff
created some seed
TammyHer Nov 30, 2015
aa71225
i MADE AN EDIT BUTTON
TammyHer Nov 30, 2015
72475cf
made new links for albums
TammyHer Dec 1, 2015
998cc26
the upvote is working... whhhhoooo
TammyHer Dec 1, 2015
b11a522
made an index page for albums
TammyHer Dec 1, 2015
da7e1e1
completed views and controller for movies (exapt delete)
TammyHer Dec 1, 2015
babed91
completed 3 models most view and controllers
TammyHer Dec 1, 2015
e68f880
made link to movie's name
TammyHer Dec 1, 2015
c64fc6a
fixed some bugs in the indexes
TammyHer Dec 1, 2015
93dfe18
made an if statement so the upvote will work in both different pages
TammyHer Dec 1, 2015
9beadeb
all deleting are working
TammyHer Dec 1, 2015
993546e
set a default rank=0, and made the validations and display the user i…
TammyHer Dec 1, 2015
f079caa
fixed some bugs - ready for testing
TammyHer Dec 1, 2015
0a98e48
got all my test to work in movies controller
TammyHer Dec 2, 2015
aad7dbb
made most of the test- include upvote
TammyHer Dec 2, 2015
4371636
upvote_i works in movies
TammyHer Dec 2, 2015
e66d3a9
only one more test and I'm good to go
TammyHer Dec 2, 2015
3d33ca3
yay got 91%. I'm good to go
TammyHer Dec 2, 2015
e22e549
did some nice bootstrap - table and index
TammyHer Dec 2, 2015
6de9d81
added some more bootstrap - DELETE button and nice table
TammyHer Dec 3, 2015
563a06d
I put the buttons in the same line as BUTTON and not link_to
TammyHer Dec 3, 2015
166ea54
bootstrap and hello kitty
TammyHer Dec 3, 2015
4050037
i think I'm done. now needs to dry things
TammyHer Dec 3, 2015
04ecc23
made list of 10 from each on the home page
TammyHer Dec 3, 2015
54cbacc
done
TammyHer Dec 4, 2015
fedf322
final stuff
TammyHer Dec 5, 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
10 changes: 8 additions & 2 deletions Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,9 @@ gem 'rails', '4.2.5'
# Use sqlite3 as the database for Active Record
gem 'sqlite3'
# Use SCSS for stylesheets
gem 'sass-rails', '~> 5.0'
gem 'bootstrap-sass', '~> 3.3.6'
gem 'sass-rails', '>= 3.2'

# Use Uglifier as compressor for JavaScript assets
gem 'uglifier', '>= 1.3.0'
# Use CoffeeScript for .coffee assets and views
Expand All @@ -23,6 +25,8 @@ gem 'jbuilder', '~> 2.0'
# bundle exec rake doc:rails generates the API under doc/api.
gem 'sdoc', '~> 0.4.0', group: :doc



# Use ActiveModel has_secure_password
# gem 'bcrypt', '~> 3.1.7'

Expand All @@ -40,8 +44,10 @@ 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 'rspec-rails'

# Spring speeds up development by keeping your application running in the background. Read more: https://github.com/rails/spring
gem 'spring'
gem 'simplecov'
end

41 changes: 40 additions & 1 deletion Gemfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -37,10 +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)
coderay (1.1.0)
coffee-rails (4.1.0)
coffee-script (>= 2.2.0)
railties (>= 4.0.0, < 5.0)
Expand All @@ -49,6 +60,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 Down Expand Up @@ -101,6 +114,23 @@ 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)
sass (3.4.19)
sass-rails (5.0.4)
railties (>= 4.0.0, < 5.0)
Expand All @@ -111,6 +141,11 @@ GEM
sdoc (0.4.1)
json (~> 1.7, >= 1.7.7)
rdoc (~> 4.0)
simplecov (0.11.1)
docile (~> 1.1.0)
json (~> 1.8)
simplecov-html (~> 0.10.0)
simplecov-html (0.10.0)
spring (1.5.0)
sprockets (3.4.1)
rack (> 1, < 3)
Expand Down Expand Up @@ -139,13 +174,17 @@ PLATFORMS
ruby

DEPENDENCIES
better_errors
bootstrap-sass (~> 3.3.6)
byebug
coffee-rails (~> 4.1.0)
jbuilder (~> 2.0)
jquery-rails
rails (= 4.2.5)
sass-rails (~> 5.0)
rspec-rails
sass-rails (>= 3.2)
sdoc (~> 0.4.0)
simplecov
spring
sqlite3
turbolinks
Expand Down
Binary file added app/assets/images/kitty.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/
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/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/javascripts/welcome.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/
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,29 @@
* 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
*/

@import "bootstrap-sprockets";
@import "bootstrap";

.button_to {
display: inline-block;
}

#upvote {
display: block;
margin-right: 1200px;
margin-bottom: 20px;
}

.page-header {
background: url(http://www.picgifs.com/glitter-gifs/h/hello-kitty/picgifs-hello-kitty-6615712.gif);

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.

background-repeat: no-repeat;
// padding-bottom: 9px;
margin: 40px 0px 20px;
border-bottom: 1px solid #EEE;
}

.page-header h1 {
margin-left: 150px;
}
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/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/
3 changes: 3 additions & 0 deletions app/assets/stylesheets/welcome.scss
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/
63 changes: 63 additions & 0 deletions app/controllers/albums_controller.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
class AlbumsController < ApplicationController

def get_album

Choose a reason for hiding this comment

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

I love your get_album method! You could also set this as a private helper method that you call in a before acton at the top of your controller. Example: before_action :get_album, only: [:edit, :show, :update] The same can be done for your get_movie and get_book methods in their corresponding controllers.

@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

Choose a reason for hiding this comment

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

Minor refactor, you could bump get_album up above the beginning of your if statement since it needs to be called regardless of the :class

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

Choose a reason for hiding this comment

The 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
64 changes: 64 additions & 0 deletions app/controllers/movies_controller.rb
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
9 changes: 9 additions & 0 deletions app/controllers/welcome_controller.rb
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
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
Loading