best_in_place and html_safe

家住魔仙堡 提交于 2019-12-24 11:58:04

问题


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:

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:

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:


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

gem 'htmlentities'
gem 'RedCloth'

find gem documentation here

Ruby gems



来源:https://stackoverflow.com/questions/20737192/best-in-place-and-html-safe

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!