Warning: file_get_contents(/data/phpspider/zhask/data//catemap/5/tfs/3.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Ruby on rails 3.1 与红地毯减价合作,打造最佳宝石_Ruby On Rails 3.1 - Fatal编程技术网

Ruby on rails 3.1 与红地毯减价合作,打造最佳宝石

Ruby on rails 3.1 与红地毯减价合作,打造最佳宝石,ruby-on-rails-3.1,Ruby On Rails 3.1,对于我的标记文本,我通常对文本内容(@user.content)执行以下操作: 不过我现在用的是最好的宝石 <%= best_in_place(@question, :statement, :path => {:controller => "users", :action => "update"}, :type => :textarea) %> {:controller=>“users”,:action=>“update”},:type=>:textar

对于我的标记文本,我通常对文本内容(@user.content)执行以下操作:


不过我现在用的是最好的宝石

<%= best_in_place(@question, :statement, :path => {:controller => "users", :action => "update"}, :type => :textarea) %>
{:controller=>“users”,:action=>“update”},:type=>:textarea)%>
我如何将红毯与此集成?我试过这个:

<%= Redcarpet.new(best_in_place(@question, :statement, :path => {:controller => "users", :action => "update"}, :type => :textarea)).to_html.html_safe %>
{:controller=>“users”,:action=>“update”},:type=>:textarea))。to_html.html_safe%>

然而,产出并不是预期的。最好的自述文件似乎指出了一种解决这个问题的方法,但我不明白,在标题为“使用自定义显示方法”的部分下。有人能给我解释一下我是如何做到这一点的吗?

我从来没有使用过最好的宝石,所以我没有尝试过。但根据文档,您应该执行以下步骤:

  • 在对
    最佳位置的调用中添加附加参数
    :display\u as
  • 在模型对象中实现
    :display_as
    引用的方法
  • 详情如下:

    附加参数 模型中的实现
    课堂问题

    require 'redcarpet'
    
    def mk_statement
       Redcarpet.new(self.statement).to_html.html_safe
    end
    

    您还可以使用带有
    属性的
    display\u,并向其传递一个
    proc
    ,如下所示:

    <%= best_in_place(@question, :statement, :display_with => proc { |v| Redcarpet.new(v).to_html.html_safe, :path => {:controller => "users", :action => "update"}, :type => :textarea) %>
    
    proc{v|red地毯.new(v).to_html.html_safe,:path=>{:controller=>“users”,:action=>“update”},:type=>:textarea)%>
    
    require 'redcarpet'
    
    def mk_statement
       Redcarpet.new(self.statement).to_html.html_safe
    end
    
    <%= best_in_place(@question, :statement, :display_with => proc { |v| Redcarpet.new(v).to_html.html_safe, :path => {:controller => "users", :action => "update"}, :type => :textarea) %>