Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8402821
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 9, 20262026-06-09T22:10:20+00:00 2026-06-09T22:10:20+00:00

Consider a passage (~400 characters) in a database table(text). Like There is only one

  • 0

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?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-09T22:10:22+00:00Added an answer on June 9, 2026 at 10:10 pm

    Assuming you have a model Passage with a field text, you can select specific field (and use SQL functions within) like this:

    passages = Passage.select("id, LEFT(text,10) as text_short, CHAR_LENGTH(text) as text_length")
    # => [#<Passage id: 1>, #<Passage id: 2>, #<Passage id: 3>]
    passages.first.id
    # => 1
    passages.first.text_short
    # => "There is o"
    passages.first.text_length
    # => 453
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Consider the Oracle emp table. I'd like to get the employees with the top
Consider the following function that implements non-blocking access to only the one thread. public
Consider the following URL: http://www.iamsomeweiredurl.fromsomewhere/andIwant#thisfragment Is there a chance to get thisfragment by @RequestMapping
Consider 3 regex expressions designed to remove non Latin characters from the string. String
Consider such html piece: <p>foo</p><p>bar</p> If you run (for example) jQuery text for it
consider this function: jQuery.fn.MyFunction = function (event) { alert(this.text()); } I want to call
Consider, please this setup for a database backed application. ( in my case DB
Consider that we are given an isometric grid (consider something like Diablo) of tiles.
Consider an article inside a div that has many <p> tag. Is there any
Consider this scenario. We have an internal Rails 2 app that connects to a

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.