tap/app/controllers/users_controller.rb

31 lines
545 B
Ruby
Raw Normal View History

2014-11-06 16:25:27 +01:00
class UsersController < ApplicationController
def new
2014-11-23 21:12:31 +01:00
@user = User.new
2014-11-06 16:25:27 +01:00
end
def show
2014-11-23 21:12:31 +01:00
@user = User.find(params[:id])
2014-11-09 22:53:39 +01:00
@orders = @user.orders.paginate(page: params[:page])
2014-11-06 16:25:27 +01:00
end
2014-11-06 18:30:53 +01:00
def create
2014-11-23 21:12:31 +01:00
@user = User.new(user_params)
if @user.save
2014-11-06 20:07:18 +01:00
redirect_to @user
else
2014-11-23 21:12:31 +01:00
render 'new'
2014-11-06 20:07:18 +01:00
end
end
2014-11-23 21:12:31 +01:00
def index
@users = User.all
end
2014-11-06 20:07:18 +01:00
2014-11-23 21:12:31 +01:00
private
2014-11-06 22:53:11 +01:00
2014-11-24 21:45:32 +01:00
def user_params
params.require(:user).permit(:name, :last_name, :password,
:password_confirmation, :nickname)
end
2014-11-06 16:25:27 +01:00
end