Skip to content

Instantly share code, notes, and snippets.

@jongillies
Created July 15, 2013 22:22
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jongillies/6004025 to your computer and use it in GitHub Desktop.
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)
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