Rails中的Mercury Editor不保存更改

Ext*_*tas 8 ruby-on-rails mercury-editor

我想用一些Visual Editor改进我的页面,并找到关于Mercury编辑器的这个轨道广播.All Done's,但是当我按下SAVE时,我已经重定向到我的页面而没有任何变化.没有错误,没有警告,只是未保存的格式化.任何人都可以帮助我吗?
一些代码:
# routes:

mount Mercury::Engine => '/'

resources :tasks do
  resources :comments
  member { post :mercury_update }
end

# My controller:

def mercury_update
  task = Task.find(params[:id])
  task.title = params[:title][:value]
  task.body_task = params[:body_task][:value]
  task.save!
  render text: ""

end


# In views/layouts/mercury.html.erb

new Mercury.PageEditor(saveUrl, {
    saveStyle:  'form', // 'form', or 'json' (default json)
    saveMethod: null, // 'PUT', or 'POST', (create, vs. update -- default PUT)
    visible:    true  // boolean - if the interface should start visible or not
  });
 #when using 'POST' i have alert 'Mercury was unable to save to the url'
Run Code Online (Sandbox Code Playgroud)

# routes:

mount Mercury::Engine => '/'

resources :tasks do
  resources :comments
  member { post :mercury_update }
end

# My controller:

def mercury_update
  task = Task.find(params[:id])
  task.title = params[:title][:value]
  task.body_task = params[:body_task][:value]
  task.save!
  render text: ""

end


# In views/layouts/mercury.html.erb

new Mercury.PageEditor(saveUrl, {
    saveStyle:  'form', // 'form', or 'json' (default json)
    saveMethod: null, // 'PUT', or 'POST', (create, vs. update -- default PUT)
    visible:    true  // boolean - if the interface should start visible or not
  });
 #when using 'POST' i have alert 'Mercury was unable to save to the url'
Run Code Online (Sandbox Code Playgroud)

PS Rails 3.2.8,水银轨道(0.8.0)

Dea*_*ean 0

我设法在您要编辑的页面(例如“pages/show.html.erb”)中使用它来设置 saveURL:

<script>
   jQuery(window).on('mercury:ready', function() { Mercury.saveUrl = '/pages/' + <%= @page.id %> + "/mercury_update"; });
</script>
Run Code Online (Sandbox Code Playgroud)