Created
July 15, 2013 22:22
-
-
Save jongillies/6004025 to your computer and use it in GitHub Desktop.
How can i do for create or update using the API with RocketPants (From: https://github.com/filtersquad/rocket_pants/issues/5)
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class UsersController < RocketPants::Base | |
version 1 | |
def index | |
expose User.paginate per_page: 10, page: params[:page] | |
end | |
def show | |
expose user | |
end | |
def update | |
user.update_attributes! params[:user] | |
expose user | |
end | |
def create | |
expose User.create!(params[:user]), status: :created | |
end | |
def destroy | |
user.destroy | |
redirect_to users_path(version: 1) | |
end | |
private | |
def user | |
@user ||= User.find(params[:id]) | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment