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 9090083
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 16, 20262026-06-16T22:17:41+00:00 2026-06-16T22:17:41+00:00

I am using CKEditor for my blogging app, and am saving formatting data in

  • 0

I am using CKEditor for my blogging app, and am saving formatting data in my :content attribute.

For example, a particular @post.content may start out like this.

<p>\r\n\t<span class=\"s1\" style=\"color: rgb(51, 51, 51); font-family: 'Helvetica Neue', Helvetica, Arial, sans-serif; font-size: 1.1em; line-height: 1.7em;\">This is my text starting here. This is an really awesome entry, you see...

The first part of the entry is all formatting data, and the actual written content starts with “This is my text starting here…”

What I would like to do is display the first fifty characters of the written content.

I tried something like this,

<%= post.content.first(50).try(:html_safe) %>

But this doesn’t return anything, unless the formatting data is less than fifty characters.

How can I go about displaying the first fifty characters of written content?

Please let me know if this is unclear, or if any additional info is needed. Thanks much for your help!

  • 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-16T22:17:42+00:00Added an answer on June 16, 2026 at 10:17 pm

    try using strip_tags method

    e.g.

     <%= truncate(strip_tags(post.content), :length => 50, :omission => '..').html_safe %>
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am using ckeditor in phpbb. when adding content in my post page. I
When a form with a textarea using CkEditor is submitted using ajax the post
I'm using CKEditor for a Content Management System. When someone edits the text on
I am using CKEditor in my web app and new to it. It seems
i am using ckeditor,now i want to translate the content in onChange event using
I am using ckeditor for a micro blog app and and every time i
iam using ckeditor in my website to add the content to the pages. But
I am using CKEditor + CKFinder to create a blog post with images in
I'm using CKEditor in Markdown format to submit user created content. I would like
I am using ckeditor to format some data inside my textarea <textarea id=editorAbout rows=70

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.