Answer the question
In order to leave comments, you need to log in
Communication between models?
There are two models Album, Song
How to do what would when you navigate through Album - give a list of Song to it.
album.rb(models)
class Album < ActiveRecord::Base
has_many :songs
end
class Song < ActiveRecord::Base
belongs_to :album
end
Answer the question
In order to leave comments, you need to log in
The next step is described here.
You need to add to the album controller
def show
@album = Album.find(params[:id])
@songs = @album.songs
end
<% @songs.each do |song| %>
<%= link_to song.name, song %>
<% end %>
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question