1

Should have been very easy but somehow cannot get it to work. I want to display truncated text on my blog home page with a 'read more' link that shows up inline with the text i.e.

Lorem ipsum dolor sit amet, consectetur adipiscing elit. Mauris ac tortor et felis aliquet vestibulum sed in sem. Aliquam pharetra ultricies nunc, non pellentesque ... Read More

Since I use simple_format for my text, all breaks in the text get wrapped in

tags and I get Read More in a separate line as below

Lorem ipsum dolor sit amet, consectetur adipiscing elit. Mauris ac tortor et felis aliquet vestibulum sed in sem. Aliquam pharetra ultricies nunc, non pellentesque ...

Read More

How do I place it inline after a < p > tag. Guess it's more of a CSS question rather than a Rails one. Again, I feel this should be super simple. What am I forgetting?

Here's the code snippet in the view

<%= simple_format truncate(h(feed.description), length: 400, separator: ' ') %><%= link_to "Read More", feed_path(feed)%> 
2
  • 1
    what does your view code currently look like? Commented Aug 31, 2012 at 17:45
  • Yes, please show us the code so we can show you how to alter it. Commented Sep 5, 2012 at 9:08

1 Answer 1

2

I suspect that you can just put your link inside the simple_format content-parameter link this:

<%= simple_format truncate((h(feed.description) + link_to("Read More", feed_path(feed))), length: 400, separator: ' ') %> 

(Note: not tested)

Sign up to request clarification or add additional context in comments.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.