30 lines
545 B
Ruby
30 lines
545 B
Ruby
class UsersController < ApplicationController
|
|
def new
|
|
@user = User.new
|
|
end
|
|
|
|
def show
|
|
@user = User.find(params[:id])
|
|
@orders = @user.orders.paginate(page: params[:page])
|
|
end
|
|
|
|
def create
|
|
@user = User.new(user_params)
|
|
if @user.save
|
|
redirect_to @user
|
|
else
|
|
render 'new'
|
|
end
|
|
end
|
|
|
|
def index
|
|
@users = User.all
|
|
end
|
|
|
|
private
|
|
|
|
def user_params
|
|
params.require(:user).permit(:name, :last_name, :password,
|
|
:password_confirmation, :nickname)
|
|
end
|
|
end
|