我想使用Mercury Editor(https://github.com/jejacks0n/mercury)編輯我的RoR應用程序的博客區域中的帖子。我沒有任何頁面模型,我只想編輯帖子,而不是所有網站的頁面。我可以在沒有特定頁面控制器的情況下使用Mercury Editor嗎?
在我的routes.rb:
resources :posts do
member { post :mercury_update }
end
在我posts_controller.rb:
def mercury_update
post = Post.find(params[:id])
post.name = params[:content][:page_name][:value]
post.content = params[:content][:page_content][:value]
post.save!
render text: ""
end
而且還做了:
$(window).bind('mercury:ready', function() {
var link = $('#mercury_iframe').contents().find('#edit_link');
Mercury.saveURL = link.data('save-url');
link.hide();
});
$(window).bind('mercury:saved', function() {
window.location = window.location.href.replace(/\/editor\//i, '/');
});
而改變風格保存在 '形式' mercury.html.erb。
即使下面這些步驟,我得到這個錯誤了,當我嘗試保存在測試後改變了:
水星無法保存的網址:http://localhost:3000/blog/test
看起來你的SaveURL沒有設置正確。 #edit_link上的'save-url'是什麼? – 2012-02-14 21:44:56