Last active
December 27, 2015 02:39
-
-
Save reedlaw/7253407 to your computer and use it in GitHub Desktop.
Users controller
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 < 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