save or update with a single button

Rails 3.1.3

I have a form that can save a new entry to DB. Also jQuery ajax retrieves the saved data into the SAME form so that users can edit it.

In order to make it work, the 'save' button should function as both 'save' and 'update'. And of course, its functionality goes through conditions such as

if changed -> update

if not -> ignore or overwrite

Could anyone give me a specific example of such control method?

Thanks in advance.

soichi