title: Undefined method, wrong association or call?
body: <p>I'm trying to make cumulative show.html for each user, that displays some data from 4 different models. Those tables:</p>
  
  <p><img src="https://i.stack.imgur.com/Yv2rn.jpg" alt="fragment of database model image"></p>
  
  <p>Problem is that I dont know how to call data from Websites table for each Button. With displaying Buttons' data there is no problem.
  That part of html should looks something like this:</p>
  
  <pre><code>&lt;% if @profile.buttons.any? %&gt;
    &lt;ul&gt;
    &lt;% @buttons.each do |button| %&gt;
      &lt;li&gt;
      &lt;%= button.website.name %&gt;
      &lt;%= link_to button.user_website_url, button.user_website_url %&gt;
      &lt;/li&gt;
    &lt;% end %&gt;
    &lt;/ul&gt;
  &lt;% else %&gt;
    &lt;p&gt;None websites added. Please finish your profile creation.&lt;/p&gt;
  &lt;% end %&gt;
  </code></pre>
  
  <p>Models:</p>
  
  <pre><code>class Website &lt; ActiveRecord::Base
   has_many :buttons
   mount_uploader :logo, LogoUploader
   validates :name, presence: true, length: { maximum: 50 }
   validates :logo, presence: true
  end
  
  class Button &lt; ActiveRecord::Base
    belongs_to :profile
    belongs_to :website
    accepts_nested_attributes_for :website
    validates :description, length: { maximum: 140 }
    validates :user_website_url, presence: true, length: { maximum: 200 }
  end
  
  class Profile &lt; ActiveRecord::Base
    belongs_to :user
    has_many :buttons, :dependent =&gt; :destroy
    #...
  end
  </code></pre>
  
  <p>User Controller:</p>
  
  <pre><code>def show
    @user = User.find(params[:id])
    @profile = @user.profile
    @buttons = @profile.buttons
  end
  </code></pre>
  
  <p>At this state of everything I'm getting an error:</p>
  
  <blockquote>
    <p>undefined method `name' for nil:NilClass</p>
  </blockquote>
  
  <p>So, what is wrong with this? I've tried many variations of associations and I'm getting either the error I put above or that no Id is passing (wrong query) for each website (that I also didn't know how to deal with).</p>