Rails 3 remote update form
Rails 3 brings some nice unobstrusive javascript. This very short tutorial will show how to make simple yet powerful ajax update form.
First, grab jquery-ujs file (or gem). Next, create some model and REST controller.
Controller needs a small change:
Thats pretty self explaining: when object is valid send notice message, else send errors as json array.
View:
Only the :remote => true part is important.
Some JavaScript
This code will take remote form and register callbacks for showing loader, notice message and errors list.
And thats all, it simply works. And yes, you have to write CSS on your own ;]
1 Notes/ Hide
-
rankandfile liked this
-
teamon posted this