Intro
For this project, I decided to make it a challenging one getting into half of the course. For this project, I wanted to do a Spotify replica.
To start off I begin by starting a new rails project
rails new < project_name >
For this project, I decided to use devise in order to get my login and sign up at a much faster paste in order to do this I downloaded
gem 'devise'
and created a
root 'welcome/home'
To send all of my users to the home page when loading up rails to the default homepage I wanted users to be directed to. This made it simple due to the fact that it creates your registration forms for you saving me some time. all I had to do was to make sure I was
link_to
the right places in order for the users to be redirected to the specific sign-in/sign-up form.
Devise is an amazing gem that enabled me to use cool quirks such as
authenthicate_user!
which enables my project to not let anyone in certain routes without proper authentication
After my root home and sign up and sign in were working I started to think about how I wanted to do this project. to start off I had to get an idea of what Spotify did in order for me to get some idea as to what I wanted to do. After several hours I thought of a simple but nice way to go about this. I started by figuring out how I was going to make specific calls to the API. as I searched through Spotify's documentation I found that it was definitely not user friendly so I dug around more and ran into this gem called
gem 'rspotify'
which enabled me to create methods with exampled they provided to make calls into the database all I needed was a
Sessions Secret And App ID
After I got that working I handled my controllers.
albums, artists, comments, omniauth, playlists, tracks, and welcome controllers
This gave me the ability to get started on making calls to the API to let me do what I needed to do. to be more specific, our users who sign up are going to have the ability to search for an artist, retrieve that artist, and then add it to their playlist collection.
def search
end
def index
if !params[:artist_name].empty?
@artists = RSpotify::Artist.search(params[:artist_name])
else
redirect_to root_path
end
end
def show
@artist = RSpotify::Artist.find(params[:id])
respond_to do |f|
f.html {render :show}
f.json {render json: @artist.albums}
end
end
Then the user has the ability to listen to the track leave a comment and delete it from their playlist if they want to. Users who are not signed in also have the ability to search for tracks and look through the featured items home tracks but not be able to create a playlist, listen to Spotify, and leave comments.
Challenges
Some of the biggest challenges I ran into facing this project was definitely the non-user-friendly Spotify API, figuring this out took me around 2 days reading and searching but I can guarantee my googling skills leveled up a lot. and that made me confident because this was a project I took on alone with hardly any help! If I were to give myself advice starting this project off it would be to relax and use more
binding.pry
As well as take time off if I need to.
Top comments (0)