8

I want to improve my pages with some Visual Editor and have find this railcast about Mercury editor. All Done's, but when i pressed SAVE, I had redirected to my page without any changes. No errors, no warnings, just UNSAVED FORMATTING. Can anybody helps me?
Some code:
# 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'

P.S. Rails 3.2.8, mercury-rails (0.8.0)

Ben
  • 68,572
  • 20
  • 126
  • 174
Extazystas
  • 488
  • 2
  • 11
  • Double check that you have matching ends in your TaskController. – Dean Aug 30 '12 at 14:10
  • I've raised a [bug](https://github.com/jejacks0n/mercury/issues/267) as I have a similar set up to you so might be worth keeping track of it see it it could resolve your issue. – Dean Aug 30 '12 at 14:47

1 Answers1

0

I managed to set the saveURL by using this in the page that you wish to edit(such as 'pages/show.html.erb'):

<script>
   jQuery(window).on('mercury:ready', function() { Mercury.saveUrl = '/pages/' + <%= @page.id %> + "/mercury_update"; });
</script>
Dean
  • 8,668
  • 17
  • 57
  • 86