Class: SetupController

Inherits:
ApplicationController show all
Defined in:
app/controllers/setup_controller.rb

Instance Method Summary collapse

Methods inherited from ApplicationController

#current_navable, #current_navable=, #current_user, #point_navigation_to, #redirect_www_subdomain, #set_locale

Instance Method Details

#createObject



16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
# File 'app/controllers/setup_controller.rb', line 16

def create
  
  raise 'name not given' if params[:first_name].blank? or params[:last_name].blank?
  raise 'email not given' if params[:email].blank?
  raise 'no password' if params[:password].blank?
  raise 'password too short' if params[:password].length < 9
  raise 'password confirmation did not match' if params[:password] != params[:password_confirmation]
  
  user = User.new first_name: params[:first_name], last_name: params[:last_name]
  user.email = params[:email]
  user.generate_alias
  user.save!
  
   = user. 
  .password = params[:password]
  .save!
  
  user.global_admin = true
  
  if params[:application_name].present?
    Setting.app_name = params[:application_name]
  end
  
  if params[:sub_organizations].present?
    params[:sub_organizations].split("\n").each do |organization_name|
      if organization_name.present?
        corporation = Corporation.create name: organization_name
        full_members = corporation.child_groups.create name: 'full_members'
        full_members.add_flag :full_members
      end
    end
    Corporation.all.first.status_groups.first.assign_user user
  end
  
   :user_account, 
  
  flash[:notice] = I18n.t(:setup_complete)
  redirect_to root_path
  
end

#indexObject



13
14
# File 'app/controllers/setup_controller.rb', line 13

def index
end