teamon

  • Archive
  • RSS
  • Ask me anything

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 ;]

    • #ruby
    • #rails
    • #javascript
    • #jquery
  • 1 year ago
  • 1
  • Comments
  • Permalink
  • Share
    Tweet

1 Notes/ Hide

  1. rankandfile liked this
  2. teamon posted this

Recent comments

Blog comments powered by Disqus
← Previous • Next →

About

Ruby, Scala and others.

Pages

  • About
  • Projects
  • RSS
  • Random
  • Archive
  • Ask me anything
  • Mobile

Effector Theme by Carlo Franco.

Powered by Tumblr