RestResponses is a couple of useful little methods to clear up your restfull controllers, turning something like this:
def update
@user = User.find(params[:id])
@user.update_attributes!(params[:user])
respond_to do |wants|
wants.html { }
wants.xml { render :xml => @user.to_xml(:except => :hashed_password) }
end
rescue ActiveRecord::RecordNotFound
render :nothing => true, :status => 404
rescue ActiveRecord::InvalidRecord
respond_to do |wants|
wants.html { }
wants.xml { render :xml => @user.errors.to_xml }
end
endTo this:
before_filter :find_user def update @user.update_attributes!(params[:user]) responds @user end
To install: ruby script/plugin install http://rest-responses.googlecode.com/svn/trunk/rest_responses