Skip to content

Instantly share code, notes, and snippets.

@reedlaw
Last active December 27, 2015 02:39
Show Gist options
  • Save reedlaw/7253407 to your computer and use it in GitHub Desktop.
Save reedlaw/7253407 to your computer and use it in GitHub Desktop.
Users controller
class UsersController < ApplicationController
respond_to :html
before_filter :authenticate_user!
def user_params
params.require(:user).permit :first_name, :last_name, :email, :password, :password_confirmation, :phone
end
private :user_params
def index
@response = BrowseUsers.new(@request).call.extend(UserPresenter)
respond_with @response
end
def show
@response = LoadUser.new(@request).call
respond_with @response
end
alias_method :edit, :show
def new
@response = NewUser.new(@request).call
respond_with @response
end
def create
@request.object_attributes = user_params
@response = SaveUser.new(@request).call
respond_with @response.user, location: users_path
end
alias_method :update, :create
def destroy
@response = DeleteUser.new(@request).call
respond_with @response, location: users_path
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment