Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
9 changes: 9 additions & 0 deletions app/controllers/artists_controller.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
class ArtistsController < ApplicationController
def index
@artists = Artist.all
end

def show
@artist = Artist.find(params[:id])
end
end
6 changes: 6 additions & 0 deletions app/controllers/dashboard_controller.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
class DashboardController < ApplicationController
def index
@recent_tracks = Track.order(created_at: :desc).limit(5)
@recent_comments = Comment.order(created_at: :desc).limit(5)
end
end
9 changes: 9 additions & 0 deletions app/controllers/tracks_controller.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
class TracksController < ApplicationController
def index
@tracks = Track.all
end

def show
@track = Track.find(params[:id])
end
end
9 changes: 9 additions & 0 deletions app/views/artists/index.html.erb
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
<h1>All Artists</h1>

<ul>
<% @artists.each do |artist| %>
<li>
<%= link_to artist.name, artist_path(artist) %>
</li>
<% end %>
</ul>
11 changes: 11 additions & 0 deletions app/views/artists/show.html.erb
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
<h1><%= @artist.name %></h1>

<h2>Tracks</h2>
<ul>
<% @artist.tracks.each do |track| %>
<li>
<%= link_to track.title, track_path(track) %>
(<%= track.year %>)
</li>
<% end %>
</ul>
23 changes: 23 additions & 0 deletions app/views/dashboard/index.html.erb
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
<h1>Dashboard</h1>

<h2>Recent Tracks</h2>
<ul>
<% @recent_tracks.each do |track| %>
<li>
<%= link_to track.title, track_path(track) %>
— <%= link_to track.artist.name, artist_path(track.artist) %>
(<%= track.year %>)
</li>
<% end %>
</ul>

<h2>Recent Comments</h2>
<ul>
<% @recent_comments.each do |comment| %>
<li>
<%= comment.user.username %> on
<%= link_to comment.track.title, track_path(comment.track) %>:
"<%= comment.body %>"
</li>
<% end %>
</ul>
11 changes: 11 additions & 0 deletions app/views/tracks/index.html.erb
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
<h1>All Tracks</h1>

<ul>
<% @tracks.each do |track| %>
<li>
<%= link_to track.title, track_path(track) %>

<%= track.artist.name %> (<%= track.year %>)
</li>
<% end %>
</ul>
27 changes: 27 additions & 0 deletions app/views/tracks/show.html.erb
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
<h1><%= @track.title %></h1>
<p>
Artist: <%= @track.artist.name %><br>
Year: <%= @track.year %><br>
BPM: <%= @track.bpm %>
</p>

<h2>Samples Used</h2>
<ul>
<% @track.sampled_tracks.each do |source| %>
<li><%= link_to source.title, track_path(source) %> - <%= link_to source.artist.name, artist_path(source) %></li>
<% end %>
</ul>

<h2>Sampled By</h2>
<ul>
<% @track.sampled_by_tracks.each do |derived| %>
<li><%= link_to derived.title, track_path(derived) %> - <%= link_to derived.artist.name, artist_path(derived) %></li>
<% end %>
</ul>

<h2>Comments</h2>
<ul>
<% @track.comments.each do |comment| %>
<li><%= comment.user.username %>: <%= comment.body %></li>
<% end %>
</ul>
4 changes: 4 additions & 0 deletions config/routes.rb
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
Rails.application.routes.draw do
# Define your application routes per the DSL in https://guides.rubyonrails.org/routing.html
resources :artists, only: [ :index, :show ]
resources :tracks, only: [ :index, :show ]

get "/dashboard", to: "dashboard#index"

# Reveal health status on /up that returns 200 if the app boots with no exceptions, otherwise 500.
# Can be used by load balancers and uptime monitors to verify that the app is live.
Expand Down