How to refactor the following Rails erb code? -


i need refactor code using link_to method.

 <a href="post.html">        <h2 class="post-title">                 <%= post.title %>        </h2>        <h3 class="post-subtitle">                 <%= post.subheading %>        </h3>  </a>  

i want this:

 <%= link_to ".........",post) %> 

the "......" refactored code.

you need pass block link_to:

<%= link_to post_url(@post) %>   <h2 class="post-title">     <%= post.title %>   </h2>   <h3 class="post-subtitle">     <%= post.subheading %>   </h3> <% end %> 

Comments

Popular posts from this blog

Qt4: how to send QString inside a struct via QSharedMemory -

node.js - NodeJS remote terminal to Dropbear OpenWRT-Server -

python - jinja2: TemplateSyntaxError: expected token ',', got 'string' -