title: How to use Ruby on Rails Associations?
body: <p><strong>Description:</strong> I am following the toy_app tutorial on: <a href="https://www.railstutorial.org/book/toy_app" rel="nofollow noreferrer">https://www.railstutorial.org/book/toy_app</a></p>
  <p>I am having issues with an Exercise question under section 2.3.3</p>
  <p><strong>Question:</strong> Edit the user show page to display the content of the user’s first micropost. (Use your technical sophistication (Box 1.1) to guess the syntax based on the other content in the file.) Confirm by visiting /users/1 that it worked.</p>
  <p>Within my <em>app/views/users/show.html.erb</em> file. I tried using my <strong>@micropost.content</strong> object to display any content associated with the user.</p>
  <pre><code>&lt;p id=&quot;notice&quot;&gt;&lt;%= notice %&gt;&lt;/p&gt;
  
  &lt;p&gt;
    &lt;strong&gt;Name:&lt;/strong&gt;
    &lt;%= @user.name %&gt;
  &lt;/p&gt;
  
  &lt;p&gt;
    &lt;strong&gt;Email:&lt;/strong&gt;
    &lt;%= @user.email %&gt;
  &lt;/p&gt;
  
  &lt;p&gt;
    &lt;strong&gt;Content:&lt;/strong&gt;
    &lt;%= (&lt;%= @micropost.content %&gt;) %&gt;
  &lt;/p&gt;
  
  
  &lt;%= link_to 'Edit', edit_user_path(@user) %&gt; |
  &lt;%= link_to 'Back', users_path %&gt;
  </code></pre>
  <p><strong>Result</strong></p>
  <blockquote>
  <p>NoMethodError in Users#show</p>
  <p>undefined method 'content' for nil:NilClass</p>
  </blockquote>
  <p><strong>Conclusion</strong></p>
  <p>Do I need to generate a <strong>form_for</strong> for my posts for my <em>app/view/user</em> file? Or, because I'm setting my <strong>:content</strong> object within a private 'micropost_params' method in my microposts_controller.rb, that it will not allow object data transfer between controllers?</p>
  <p>I tested within console the following lines of code to make sure association is working:</p>
  <pre><code>first_user = User.first
  first_user.microposts
  micropost = first_user.microposts.first
  micropost.user
  </code></pre>
  <p>I feel that I need to define a method within my User controller file that gives access to my :content object within my MicroPosts Class.</p>