Ajax In place editor to send modifications

Hi,

I have a requirement to use an Ajax in place editor on a set of snippets to allow user to modify existing content. Once edited, however, I want the ok button to NOT modify the original snippet, but instead, send the content to another action, which then updates a different object.

Currently, I have the following code:

_snippets.html.erb

<%for snippet in @snippets%>

<p id='snippet_<%=[snippet.id](http://snippet.id)%>'>...<%= snippet.paragraph %>...</p>

<%= set_page_snippet_url = url_for(

:controller => 'books',

:action => 'set_page_snippet',

:snippet_id => [snippet.id](http://snippet.id),

:relative_id => @[relative.id](http://relative.id)

)%>

<script type="text/javascript">

 new Ajax.InPlaceEditor('snippet_<%=[snippet.id](http://snippet.id)%>', '#{set_page_snippet_url}' , {rows:15,cols:50});

</script>

<%end%>

books_controller.rb

def set_page_snippet

end

The problem I see is:

  1. the set_page_snippet never fires (when I add a debugger line to set_page_snippet)

  2. On clicking ok after editing a snippet, the snippet that was edited changes to show the home page

How can I get the original snippet to remain unchanged after edit and have the set_page_snippet to fire (with params[:value] containing the edited text)?

Thanks

Anand