Quantico
Quantico

Reputation: 2436

placing links correctly using ruby on rails

I am trying to create some sort of a sticky note using the css from step 1 in the following link http://net.tutsplus.com/tutorials/html-css-techniques/create-a-sticky-note-effect-in-5-easy-steps-with-css3-and-html5/

I am using ruby on rails to generate the notes with the following code

<ul>
      <% @posts.each do |post| %>
      <li>
          <a>    
             <p><strong>Title:</strong>
             <%= post.title %></p>

          </a>
     </li>
     <% end %>
</ul>

everything is working fine but when I am trying to add a link to the post I am getting the link added in a different post

for example

<ul>
      <% @posts.each do |post| %>
      <li>
          <a>    
             <p><strong>Title:</strong>
             <%= post.title %>
             <%= link_to 'Show', post, :class => 'text' %></p>

          </a>
     </li>
     <% end %>
</ul>

any ideas?

Upvotes: 0

Views: 34

Answers (1)

rails_id
rails_id

Reputation: 8220

Try this

<ul>
 <% @posts.each do |post| %>
 <li>
 <%= link_to post, :class => 'text' do %>
   <p>
     <strong>Title:</strong>
     <%= post.title %>
   </p>
 <% end %>
 </li>
 <% end %>
</ul>

link_to method rails

Upvotes: 1

Related Questions