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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 4, 20262026-06-04T17:19:28+00:00 2026-06-04T17:19:28+00:00

I am using best_in_place gem to do some inline editing in a Rails app.

  • 0

I am using best_in_place gem to do some inline editing in a Rails app.

One of the property of my object is of type text, and I want it to be edited in a text area, so I did this:

<%= best_in_place @myobject, :description, :type => :textarea %>

It works, but when not being edited, all returns (\n) are removed.

I tried using simple_format, by adding :display_with => :simple_format to the options passed to best_in_place:

<%= best_in_place @myobject, :description, :type => :textarea, :display_with => :simple_format %>

When not being edited, the new lines are displayed as expected. But the click to enter edition is broken, and a new dash is added above. Clicking it display a textarea box, but it is empty, and the text entered there is not saved back to my object.

The content saved in my property is just plain text, it does not contain any html.


This issue (and patch) seemed related to my problem: https://github.com/bernat/best_in_place/pull/111
However, when applying the patch (manually, to the file .../gems/best_in_place-1.0.6/spec/spec_helper.rb), I still have the same problem.

  • 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-04T17:19:30+00:00Added an answer on June 4, 2026 at 5:19 pm

    I had the same problem and solved it by binding to the “ajax:success” event as described in the best_in_place documentation and converting the new lines to <br />‘s.

    $('.best_in_place').bind('ajax:success', function(){ this.innerHTML = this.innerHTML.replace(/\n/g, '<br />') });
    

    You could also choose to use a lightweight markup language like textile or markdown instead of simple line breaks. Javascript converters for these can be found here (textile) and here (markdown).

    I went with Textile since I could just use the textilize method in best_in_place’s display_with option.

    The updated javascript:

    $('.best_in_place').bind('ajax:success', function(){ $(this).JQtextile('textile', this.innerHTML) });
    

    Also, if you only want this behavior on best_in_place textareas you can check for the data-type attribute:

    $('.best_in_place').bind('ajax:success', function(){ 
        if ($(this).attr('data-type') == 'textarea')
            $(this).JQtextile('textile', this.innerHTML) 
    });
    

    Lastly, match the conversion on the server side:

    :display_with => lambda { |v| textilize(v).html_safe } // the RedCloth gem may be required.
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am using the best_in_place gem to edit records inline and country_select to render
I'm using the best_in_place gem to edit balances: index.html.erb: <%= best_in_place bankaccount, :balance, :display_with
What is the best method of using native menus in C#? Edit: I want
I am currently building a Rails app, and trying to figure out the best
we're developing a Facebook Canvas App in Rails 2.3.8, we tried a couple of
Here is my Gemfile : source 'http://rubygems.org' gem 'rails', '3.0.0' gem 'sqlite3-ruby', :require =>
I'm trying to parallelise the Floyd-Warshall algorithm using OpenMP (basically editing a 2D array
I'm using CakePHP for a web app to upload photos. Ideally i'd like to
I'm using the latest RC of Rails 3.1 and I can't seem to find
After upgrading my Rails 3.0.9 app to 3.1.1, I'm getting the following bundler error

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.