best_in_place and html_safe

610 views Asked by At

I'm using the best_in_place gem in my rails app to allow for inline editing. I'm running into issues with trying to render some text html safe.

Without specifying that the text should be made html_safe, this is what it looks like on the page:enter image description here

I looked at the best_in_place documentation and tried adding the following lines to render the text html safe:

  <div id="projectOverviewDescription">
      <p>

  <%= best_in_place @project.overview, :description, 
    :path => project_step_path(@project, @project.overview), 
    :type => :textarea, 
    :nil=> "Add a description of your project here!", 
    :display_with => lambda { |v| v.html_safe } %>

  </p>
</div>

But this ends up looking like the following:

enter image description here

It looks like the text ignores my css overflow rules and also, the best_in_place editing uses the nil placeholder ("add a description...") when there is a description already. What's the best way to produce html_safe text using best_in_place?

Here's my css:

#projectOverviewDescription{
  position: absolute;
  top: 0;
  right: 0;
  width: 250px;
  padding: 20px;
  float: right;
  height: 236px;
  border-top-right-radius: 7px;
  border-bottom-right-radius: 7px;
  background: $titlegrey;
  opacity: 0.7;
  p{
    color: white;
    height: 236px;
    overflow-y: scroll;
    overflow-x: hidden;
  }
}
1

There are 1 answers

1
Bharat soni On

You can try this gems that have more functionalities and may solve your problems

gem 'htmlentities'
gem 'RedCloth'

find gem documentation here

Ruby gems