I'm extremely new to RoR and am experiencing a roadblock in my learning. I created a scaffold against a performers db table that has a foreign key tie to a genres table as a lookup table for the performers genres.
What I'm attempting to do is to use the the genre_id from the current performer row in a find against the genres table to extract the genre name. I have everything working as desired in the list action except I can't seem to figure out how to add a "genre_name" => @genre[:genre_name] into the @performers instance variable so that it will propagate through to the view.
In my list action, I have the following code, but am obviously doing it wrong and would really appreciate if someone could steer me right.
def list
@performer_pages, @performers = paginate :performers, :per_page => 10
@performers.each do |performer|
#logger.debug(performer[:genre_id])
@genre = Genre.find(performer[:genre_id], :select => 'genre_name')
@performers[performer[:id]][:genre_name] = @genre[:genre_name]
^-- THIS IS THE LINE I AM STUCK ON
end
logger.debug(@performers.inspect)
end
Thanks