title: Returning data from database to another page in rails
body: <p>How can I return data from the database on another page?</p>
  
  <p>I can file this under: views / posts / index.htm.erb</p>
  
  <pre><code>&lt;h1&gt;Listing posts&lt;/h1&gt;
  
  &lt;table&gt;
    &lt;tr&gt;
      &lt;th&gt;Titulo&lt;/th&gt;
      &lt;th&gt;Conteudo&lt;/th&gt;
      &lt;th&gt;Categoria&lt;/th&gt;
      &lt;th&gt;Criado em&lt;/th&gt;
      &lt;th&gt;&lt;/th&gt;
      &lt;th&gt;&lt;/th&gt;
      &lt;th&gt;&lt;/th&gt;
    &lt;/tr&gt;
  
  &lt;% @posts.each do |post| %&gt;
    &lt;tr&gt;
      &lt;td&gt;&lt;%= post.titulo %&gt;&lt;/td&gt;
      &lt;td&gt;&lt;%= post.conteudo %&gt;&lt;/td&gt;
      &lt;td&gt;&lt;%= post.category.name %&gt;&lt;/td&gt;
      &lt;td&gt;&lt;%= post.created_at.strftime("%d/%m/%Y") %&gt;&lt;/td&gt;
      &lt;td&gt;&lt;%= link_to 'Show', post %&gt;&lt;/td&gt;
      &lt;td&gt;&lt;%= link_to 'Edit', edit_post_path(post) %&gt;&lt;/td&gt;
      &lt;td&gt;&lt;%= link_to 'Delete', post, confirm: 'Are you sure?', method: :delete %&gt;&lt;/td&gt;
    &lt;/tr&gt;
  &lt;% end %&gt;
  &lt;/table&gt;
  
  &lt;br /&gt;
  
  &lt;%= link_to 'New Post', new_post_path %&gt;
  </code></pre>
  
  <p>And I wanted to display these values ​​on another page: views / home / blog.html.erb</p>
  
  <p>How do I do this? Could you explain all the steps so that I can display these values ​​in my other page.</p>
  
  <hr>
  
  <p>Thanks Kocur4d</p>
  
  <p>but how do I get only some information? eg: I would like that to appear in the title of the post page like this way (in blog.html.erb):</p>
  
  <pre><code>&lt;div class="post-title"&gt;
  &lt;h2 class="title"&gt; &lt;a href="link_to_post"&gt; **&lt;% = post.titulo%&gt;** &lt;/ a&gt; &lt;/ h2&gt;
  &lt;/ div&gt;
  </code></pre>