Q:

Displaying nested association in view in Rails 4

I have 3 models as below:
class Kick < ActiveRecord::Base
 has_many :offs
 has_many :retailers, :through => :off
end

class Retailer < ActiveRecord::Base
 has_many :offs
 has_many :kicks, :through => :off
end

class Off < ActiveRecord::Base
 belongs_to :kicks
 belongs_to :retailers
end

And I'm trying to display the name of the retailer in my 'show Kick view' as below:
  <% @kick.off.each do|off| %>
    <%= off.name %>
    <%= off.retailers.name %>
  <% end %>

Off.name displays fine but I cannot seem to index the retailer's name from this view. What am I missing?
Error:
undefined method `name' for nil:NilClass

A:

class Kick < ActiveRecord::Base
 has_many :offs
 has_many :retailers, :through => :offs
end

class Retailer < ActiveRecord::Base
 has_many :offs
 has_many :kicks, :through => :offs
end

class Off < ActiveRecord::Base
 belongs_to :kick
 belongs_to :retailer
end

also make sure you properly indexed the models in db

