Hi!
I have a list of items with description but would like to show only the
first words of the description and link to the full item detail page.
How can I do that ?
Thank you!
Hi!
I have a list of items with description but would like to show only the
first words of the description and link to the full item detail page.
How can I do that ?
Thank you!
weirdmonkey wrote:
Hi!
I have a list of items with description but would like to show only the
first words of the description and link to the full item detail page.How can I do that ?
Thank you!
Think truncate is what you need.
See
Then you can just do a link_to with “more info” as the text.
Wow !
Thank you very much Chris!
I just need to add the my view <%= product.description.truncate %> right
?
(i’m a beginner when it comes to dynamic websites so excuses my poor
knowledge hehe)
++
No prob. I’m a newb myself, though have done a little php.
Actually what you need is: <%= truncate(product.description, 50, “:::”)
%>
Those last two parameters are optional and I’ve just chosen 50 and “:::”
arbitrarily. It defaults to 30 (characters) and “…”
This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.
Sponsor our Newsletter | Privacy Policy | Terms of Service | Remote Ruby Jobs