我想用一些Visual Editor改进我的页面,并找到关于Mercury编辑器的this轨道广播。所有完成,但当我按下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'
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'
附: Rails 3.2.8,mercury-rails(0.8.0)
答案 0 :(得分:0)
我设法在您要编辑的页面中使用此设置saveURL(例如'pages / show.html.erb'):
<script>
jQuery(window).on('mercury:ready', function() { Mercury.saveUrl = '/pages/' + <%= @page.id %> + "/mercury_update"; });
</script>