Mercury编辑器无法正常工作

时间:2013-04-18 12:44:44

标签: ruby-on-rails ruby

如果我保存像'Lorem ipsum'这样的东西,那就是刷新后出现的内容:

--- !ruby/hash:ActiveSupport::HashWithIndifferentAccess RandomPageName: !ruby/hash:ActiveSupport::HashWithIndifferentAccess type: full data: !ruby/hash:ActiveSupport::HashWithIndifferentAccess {} value: lorem ipsum snippets: !ruby/hash:ActiveSupport::HashWithIndifferentAccess {} 

一切都是默认的。

github回购在这里: https://github.com/gwuix2/gerse

3 个答案:

答案 0 :(得分:2)

水银编辑器发送params的格式有点不同。有些像这样的

{"content"=>{"title"=>{"type"=>"simple", "data"=>{}, "value"=>"Hello world"}}

正常@ post.update_attributes(params [:post])不会工作。

您可以编写像

这样的私有方法
def extract_params(params)
  attr = {}
  params[:content].each { |key, value| attr[key.to_sym] = value['value'] }
  attr
end

然后调用@ post.update_attributes(extract_params(params))

答案 1 :(得分:0)

您应该确保查看Mercury的文档。 https://github.com/jejacks0n/mercury

http://railscasts.com/episodes/296-mercury-editor还有一个非常好的railscast,它有点旧,所以你必须使用文档进行更新。其中一个主要变化是在最新版本中区域的初始化方式不同。

<div id="primary" data-mercury="full">

vs

 <div id= "primary" class="mercury-region" data-type="editable">

答案 2 :(得分:0)

您可以在此处看到更好的屏幕投射:::

<http://railscasts.com/episodes?utf8=%E2%9C%93&search=mercury>