Links
Rest-Responses
Categories
Rest-Responses
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
end
To 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
Vitals
| Home | http://code.google.com/p/rest-responses/ |
|---|---|
| Repository | http://rest-responses.googlecode.com/svn/trunk/rest_responses |
| License | Rails' (MIT) |
| Tags |
REST
|
| Rating | (3 votes) |
| Owner | Alexander MacCaw |
| Created | 19 August 2007 |

