私は、ユーザーが経験と教育で履歴書を更新できるRoRアプリに取り組んでいる初心者です。これらの異なるアイテムのモデルが2つあり、時系列で一緒に表示したいと思います。プロファイルコントローラとビューでこれを設定する方法を知りたいです。
これと同じ方法を、ユーザーからの投稿アイテムとディスカッションアイテムを同じ方法で組み合わせるアプリの別の部分に採用したいと思います。しかし、現在、私の焦点は経験と教育の部分にあります。
プロファイル/show.html.erb:
<% if @experiences.any? or @educations.any? %>
<div class="postExpOuter">
<% @experiences.each do |experience| %>
<div class="postExp">
<div>
<h2><%= experience.position %></h2>
<h3><%= experience.company %> | <%= experience.location %></h3>
<h4>
<%= experience.start_month %> <%= experience.start_year %>
<% if experience.end_year %>
<%= " - " + experience.end_month %> <%= experience.end_year %>
<% else %>
<span> - Present</span>
<% end %>
</h4>
</div>
</div>
<% end %>
<% @educations.each do |education| %>
<div class="postExp">
<div>
<h2><%= education.degree %></h2>
<h3><%= education.school %></h3>
<h4>
<% if education.end_year %>
<span>Class of </span><%= education.end_year %>
<% else %>
<%= education.start_year %><span> - Present</span>
<% end %>
</h4>
</div>
</div>
<% end %>
</div>
<% end %>