Consider a passage (~400 characters) in a database table(text).
Like
There is only one more week to Easter. I have already started my
holiday. The idea of visiting my uncle during this Easter is
wonderful. His farm is in this village down in Cornwall. This village
is very peaceful and beautiful. I have asked my aunt if I can bring
Sam, my dog, with me. I promise her I will keep him under control. He
attacked and he ate some animals from her farm in October. But he is
part of the family and I cannot leave him behind.
but i need to retrieve only limited characters from that like ~150 characters only.
There is only one more week to Easter. I have already started my
holiday. The idea of visiting my uncle during this Easter is
wonderful. His farm is in this village down in Cornwall. This village
is very peaceful…
Is there any function in rails or only truncate(:limit,:option{}) function for that output?
Assuming you have a model
Passagewith a fieldtext, you can select specific field (and use SQL functions within) like this: