sometimes we need to truncate a long text more smart.
eg:
The Model layer represents your domain model (such as Account, Product,
Person, Post, etc.) and encapsulates the business logic that is specific
to
your application. In Rails, database-backed model classes are derived
from
ActiveRecord::Base. Active Record allows you to present the data from
database rows as objects and embellish these data objects with business
logic methods. Although most Rails models are backed by a database,
models
can also be ordinary Ruby classes, or Ruby classes that implement a set
of
interfaces as provided by the Active Model module. You can read more
about
Active Record in its README.
to
The Model layer represents your domain model (such as Account, Product,
Person, Post, etc.) and encapsulates the business logic that is specific
to
your application.
I create a method content_truncate https://github.com/zlx/content-truncate to
implementation my requirement. But it is so immature for merge into
activesupport
On Saturday, June 1, 2013 1:57:58 AM UTC-5, soffolk Zhu wrote:
I create a method content_truncatehttps://github.com/zlx/content-truncate to
implementation my requirement. But it is so immature for merge into
activesupport
On June 4, 2013 at 10:58:25 PM, Peter ([email protected]) wrote:
You might checkout truncate_html and consider combining your
functionality into there as options.
\Peter
It seems use for content contains html tag, while i process for pure
string without html tag
more than that, you can use it to produce your summary and save it into
database.
I think it’s a universal function, and we need not to limit it. just expand
String
If you want to, go ahead. Put it in a module, then send :include to
String with your module name.
If you really did not want suggestions, why did you ask for them? If you
already have an answer you are settled on, why open things up? Just do
it, see what you get.
On June 6, 2013 at 10:54:10 AM, Tamara T. ([email protected])
wrote:
If you want to, go ahead. Put it in a module, then send :include to
String with your module name.
If you really did not want suggestions, why did you ask for them? If you
already have an answer you are settled on, why open things up? Just do
it, see what you get.
I am sorry about yourmisunderstand, Thanks for your advices.
This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.