Performing AJAX calls on the "new" controller
Posted
by shmichael
on Stack Overflow
See other posts from Stack Overflow
or by shmichael
Published on 2010-06-06T17:05:57Z
Indexed on
2010/06/06
17:12 UTC
Read the original article
Hit count: 387
ruby-on-rails
|AJAX
In my rails app, I want to have a sortable list as part of an object creation. The best practice suggested Railscast adds the acts_as_list plugin and then initiates AJAX calls to update item position. However, AJAX calls won't work on an unsaved model, which is the situation with new.
One solution would be to save the model immediately on new and redirect to edit. This would have a nice side effect of persisting any change so the user could resume work should he be interrupted.
However, this solution adds the unwanted complexity of saving an invalid model, compromising rails' validation processes. Is there any better way to allow AJAX + validations without going into too much work?
© Stack Overflow or respective owner