-
-
Save JonnieCache/1352477 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class ArtistSearchController < ApplicationController | |
def search | |
@title = "Search" | |
end | |
def artist | |
@title = "Similar artists" | |
logger.debug "#{params[:artist].class}" | |
unless params.nil? | |
music_request = MusicRequest.new #snake_case, not camelCase | |
data = music_request.find_similar(params[:artist]) | |
#using map to build arrays | |
@similar_artists = data[:response][:artists].map do |artist| | |
artist[:name] | |
end | |
logger.debug "#{data}" | |
end | |
end | |
def list_similar | |
@title = "amazing" | |
end | |
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!DOCTYPE html> | |
<html> | |
<head> | |
<title><%= title %></title> | |
</head> | |
<body> | |
<h1>Similar artists</h1> | |
<p> | |
Here's a list of similar artists | |
</p> | |
<ul> | |
<% @similar_artists.each do |artist| %> #you only need the = in the <%= when that line will output something. this is just a loop. leave off the = | |
<li> | |
<%= artist %> | |
</li> | |
<% end %> | |
</ul> | |
</body> | |
</html> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment