Skip to content

Instantly share code, notes, and snippets.

@dnagir
Created January 13, 2012 14:51
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
Star You must be signed in to star a gist
Save dnagir/9ca5dce0524927d69655 to your computer and use it in GitHub Desktop.
class @User extends ko.Model
@persistAt 'user'
@fields 'id', 'name', 'email', 'validateRemotely'
class UsersController < ApplicationController
def update
@user = User.find params[:id]
@user.attributes = params[:user]
if @user.valid?
@user.save! unless params[:user][:validateRemotely]
render :json => @user, :status => 200
else
render :json => @user.errors, :status => 422
end
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment