Class: Clearance::UsersController

Inherits:
BaseController
  • Object
show all
Defined in:
app/controllers/clearance/users_controller.rb

Instance Method Summary collapse

Instance Method Details

#createObject



10
11
12
13
14
15
16
17
18
19
# File 'app/controllers/clearance/users_controller.rb', line 10

def create
  @user = user_from_params

  if @user.save
     @user
    redirect_back_or url_after_create
  else
    render template: "users/new", status: :unprocessable_entity
  end
end

#newObject



5
6
7
8
# File 'app/controllers/clearance/users_controller.rb', line 5

def new
  @user = user_from_params
  render template: "users/new"
end

#redirect_signed_in_usersObject (private)



23
24
25
26
27
# File 'app/controllers/clearance/users_controller.rb', line 23

def redirect_signed_in_users
  if signed_in?
    redirect_to Clearance.configuration.redirect_url
  end
end

#url_after_createObject (private)



29
30
31
# File 'app/controllers/clearance/users_controller.rb', line 29

def url_after_create
  Clearance.configuration.redirect_url
end

#user_from_paramsObject (private)



33
34
35
36
37
38
39
40
41
# File 'app/controllers/clearance/users_controller.rb', line 33

def user_from_params
  email = user_params.delete(:email)
  password = user_params.delete(:password)

  Clearance.configuration.user_model.new(user_params).tap do |user|
    user.email = email
    user.password = password
  end
end

#user_paramsObject (private)



43
44
45
# File 'app/controllers/clearance/users_controller.rb', line 43

def user_params
  params[Clearance.configuration.user_parameter] || {}
end