i'm actually working on a webApp to stream music.
I created an Album and a track model.
A track belongs_to an Album. An album has_many tracks
I'm in trouble with my show view.
I'v got an index to show all the albums and the tracks that go in.
<table> <thead>
<tr>
<td>#</td>
<td>Title</td>
<td>released_at</td>
</tr> </thead> <tbody>
<% @albums.each do |album|%>
<td><%= link_to "show", albums_path%></td>
<tr>
<td><%= album.id%></td>
<td><%= album.title %></td>
<td><%= sexy_date(album.released_at)%></td>
<td><%= time_ago_in_words(album.released_at)%></td>
<td><%= album.tracks_count%></td>
<% album.tracks.each do |track|%>
<td>
<%= track.title%>
</td>
</tr>
<% end %>
<% end %>
</tbody>
i would like to click on a specific album with my link_to
<td><%= link_to "show", albums_path%></td>
but the fact is that this code make the url localhost:3000/albums and not localhost:3000/album/1 that i'm looking for.
I understand that my link is not correct, but i can't find what to code instead.
Here is my Albums_controller
class AlbumsController < ApplicationController
# before_action :authenticate_user! # before_action :set_track, only: [:show, :edit, :update, :destroy]
def index
@albums = Album.all
end
def show end
def create
@album = Album.new(album_params) end
private
def set_album
@album = Album.find(params[:id])
end
def album_params
params.require(:album).permit(:title)
end end
Thanks for helping :)