だからここに私が取得したいものがあります: テーブル内の各アーティストについて、その名前と彼が作成した最近の 3 つの作品を投稿する必要があります。
これが私がこれまでに持っているものです:
class Artist < ActiveRecord::Base
attr_accessible :image, :name
has_many :works
end
class Work < ActiveRecord::Base
attr_accessible :artist_id, :exhibition_id, :image, :title
belongs_to :artist
belongs_to :exhibition
end
<% @artists.each do |artist| %>
<div class="one-artist">
<h3><%= artist.name %></h3>
<div class="artist-work first-work">
<%= artist.works.title %>
</div>
<% end %>
これはアーティストの作品にアプローチする方法として受け入れられると思いましたが、うまくいかないようです。
それは私に次の応答を与えます:
undefined method `title' for #<ActiveRecord::Relation:0x00000102e89038>