In my index.html.erb
file, I have:
<% @posts.each do |post| %>
<%= post.title %>
<%= link_to 'Show', post %>
<% end %>
How can I link_to the show action but having the <%= post.title =>
as the name of the link?
I've tried <%= link_to '<%= post.title %>', post %>
but it doesn't work. Am I missing something or do I need to change something?
<%= link_to post.title, post %>
More info: http://api.rubyonrails.org/classes/ActionView/Helpers/UrlHelper.html#method-i-link_to
this wil help:
<%= link_to post.title, post_path(post) %>.
Also you should read this: rails guides
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With