User Controller Flashcards

1
Q

(USER) def new

A

def new
@user = User.new
render :new
end

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
2
Q

(USER) def index

A

@users = User.all
render :index
end

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
3
Q

(USER) def create

A

@user = User.create(user_params)

if @user.save
log_in!(user)
redirect_to users_url
else
flash[:errors] = @user.errors.full_messages
render :new
end
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
4
Q

(USER) def show

A

@user = User.find(params[:id])
render :show
end

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
5
Q

(USER) def user_params

A

params.require(:user).permit(:username, :password)

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
6
Q

def edit

A

@user= User.find(params[:id])
render :edit
end

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
7
Q

def update

A
@user= User.find(params[:id])
    if @user.update_attributes(user_params)
      redirect_to cat_url(@user)
    else
      flash.now[:errors] = @user.errors.full_messages
      render :edit
    end
  end
How well did you know this?
1
Not at all
2
3
4
5
Perfectly