enterprise_registration_controller.rb
1.36 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
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
class EnterpriseRegistrationController < ApplicationController
before_filter :login_required
# Just go to the first step.
#
# FIXME: shouldn't this action present some sort of welcome message and point
# to the first step explicitly?
def index
@create_enterprise = CreateEnterprise.new(params[:create_enterprise])
@create_enterprise.requestor = current_user.person
the_action =
if request.post?
if @create_enterprise.valid_before_selecting_target?
if @create_enterprise.valid?
:confirmation
else
:select_validator
end
end
end
# default to basic_information
the_action ||= :basic_information
send(the_action)
render :action => the_action
end
protected
# Fill in the form and select your Region.
#
# Posts back.
def basic_information
@regions = environment.regions.map {|item| [item.name, item.id]}
end
# present information about validator organizations, and the user one to
# validate her brand new enterprise.
#
# Posts back.
def select_validator
@validators = @create_enterprise.region.validators
end
# Actually records the enterprise registration request and presents a
# confirmation message saying to the user that the enterprise register
# request was done.
def confirmation
@create_enterprise.save!
end
end