-
Notifications
You must be signed in to change notification settings - Fork 24
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
TunesTakeOut #11
base: master
Are you sure you want to change the base?
TunesTakeOut #11
Changes from all commits
9defff3
9f55132
7df5004
64b262c
6ed7f70
4b536d8
8b47909
575036a
4fd63f2
f494aec
6ff6b95
8b29f31
2cc7d72
edc3d7d
bf77de1
64f03a5
fadabae
0621344
929e161
b79e51d
836db83
c3aeb64
008fb24
0d2cbc1
c52d947
b8ead80
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,10 @@ | ||
SPOTIFY_CLIENT_ID: f5367bbd4d5f4886a60eade686bf8f63 | ||
SPOTIFY_CLIENT_SECRET: 6ae2a615d6424ac28af5df02b0ccc45d | ||
|
||
|
||
|
||
|
||
YOUR_CONSUMER_KEY: YyEMdut41--kJVxTsOnNqA | ||
YOUR_CONSUMER_SECRET: UZgbBTeOmLBrCHTUTCvdy-v4TY4 | ||
YOUR_TOKEN: 1pKD5WOtU89W8rorhjxCO77B_TA7-7nK | ||
YOUR_TOKEN_SECRET: qb6kS2hbWFyLGoMIxSiaShpGUos | ||
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 favorites 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 sessions 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 suggestions 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 |
---|---|---|
@@ -1,5 +1,21 @@ | ||
class ApplicationController < ActionController::Base | ||
# Prevent CSRF attacks by raising an exception. | ||
# Prevent CSRF attacks by raising an exception. | ||
# For APIs, you may want to use :null_session instead. | ||
# Prevent CSRF attacks by raising an exception. | ||
# For APIs, you may want to use :null_session instead. | ||
protect_from_forgery with: :exception | ||
helper_method :current_user | ||
|
||
before_action :require_login | ||
|
||
def current_user | ||
@user ||= User.find_by(id: session[:user_id]) | ||
end | ||
|
||
def require_login | ||
if current_user.nil? | ||
flash[:error] = "You must be logged in to view this section" | ||
redirect_to root_path | ||
end | ||
end | ||
end |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,73 @@ | ||
require 'tunestakeout.rb' | ||
|
||
class FavoritesController < ApplicationController | ||
|
||
def favorite_a_suggestion | ||
|
||
favorite = TunesTakeOut.new.favorite_a_suggestion(params[:user_id],params[:suggestion_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. why is this variable called "favorite"? It seems to be a reference to the response from an HTTP request. If so, something like "favorite_response" makes more sense. |
||
if favorite == 201 | ||
@message = "Good!" | ||
else | ||
@message = "Not so good :(" | ||
end | ||
@print_status = favorite | ||
redirect_to get_my_favs_path | ||
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. Indent the above 2 lines and the line above end. |
||
end | ||
|
||
def get_my_favs | ||
@id_array = [] | ||
@food_array = [] | ||
@music_array = [] | ||
|
||
@show_favorites = TunesTakeOut.new.my_favorites(current_user.uid) | ||
|
||
@show_favorites.each do |entire_suggestion| | ||
a = entire_suggestion["suggestion"] | ||
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. What is a? A more descriptive name would make the code easier to read. |
||
if a["music_type"] == "artist" | ||
@artist = Music.find_artist(a["music_id"]) | ||
@music_array << @artist | ||
elsif a["music_type"] == "album" | ||
@album = Music.find_album(a["music_id"]) | ||
@music_array << @album | ||
else a["music_type"] == "track" | ||
@track = Music.find_track(a["music_id"]) | ||
@music_array << @track | ||
end | ||
|
||
@food = Food.find_business(a["food_id"]) | ||
@food_array << @food | ||
|
||
id = a["id"] | ||
|
||
@id_array << id | ||
|
||
|
||
end | ||
|
||
|
||
@food_array | ||
@music_array | ||
@id_array | ||
|
||
|
||
|
||
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. Lots of unnecessary white space. |
||
render :my_favs | ||
end | ||
|
||
|
||
|
||
def destroy | ||
unfavorite = TunesTakeOut.new.unfavorite_a_suggestion(params[:user_id],params[:suggestion_id]) | ||
if unfavorite == 201 | ||
@message = "Good!" | ||
else | ||
@message = "Not so good :(" | ||
end | ||
@print_status = unfavorite | ||
redirect_to get_my_favs_path | ||
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.
Don't check in your .env file! 🙀 (add .env to gitignore file)