How would I show one of many nested objects in the index view
class Album < ActiveRecord::Base
has_many: photos
accepts_nested_attributes_for :photos,
:reject_if => proc { |a| a.all? { |k, v| v.blank?} }
has_one: cover
accepts_nested_attributes_for :cover
end
class Album Controller < ApplicationController
layout "mini"
def index
@albums = Album.find(:all,
:include => [:cover,]).reverse
respond_to do |format|
format.html # index.html.erb
format.xml { render :xml => @albums }
end
end
This is what I have so fare. I just want to show a cover for each album.
Any info on this would be a massive help!!