Rails アプリケーションで別のテーブルから列を参照しようとしています。両方のテーブル (サイトとトライアル) の一致する site_id 列を使用して、site_name を参照したいと考えています。
私のコントローラー
def list
 @list = Trial.year(params[:year]).order(:region_id)
end
マイモデル
class Trial < ActiveRecord::Base
  attr_accessible :trial_id, :site_id, :year, :trial_type, :region_id
  scope :year, ->(year) { where(year: year) }
  scope :trial_id, ->(trial_id) { where(trial_id: trial_id) }
  belongs_to :site
end
class Site < ActiveRecord::Base
  attr_accessible :site_id, :site_name, :region
  has_many :trials
end
私の見解
<table class="table">
    <th>Trial Location</th>
    <th>Trial Type</th>
    <th>Grower</th>
    <% @list.each do |list| %>
    <tr>
    <td>
  <%= link_to list.site.site_name, trial_trials_path(trial_id: list.trial_id) %>
    </td>
    <td>    
    <%= link_to list.trial_type, trial_trials_path(trial_id: list.trial_id) unless list.trial_type.blank? %>
    </td>
    <td>    
    <%= link_to list.trial_type, trial_trials_path(trial_id: list.trial_id) unless list.trial_type.blank? %>
    </td>
    </tr>
    <% end %>
</table>