Class: IshManager::EmailActionsController
Instance Method Summary
collapse
#basic_auth, #home, #tinymce
Instance Method Details
#edit ⇒ Object
8
9
10
11
12
|
# File 'app/controllers/ish_manager/email_actions_controller.rb', line 8
def edit
@act = @email_action = Office::EmailAction.find( params[:id] )
@act.ties.push Office::EmailActionTie.new( next_email_action_id: nil )
authorize! :edit, @act
end
|
#index ⇒ Object
14
15
16
17
18
|
# File 'app/controllers/ish_manager/email_actions_controller.rb', line 14
def index
@email_actions = Office::EmailAction.all
authorize! :index, @new_email_action
end
|
#new ⇒ Object
20
21
22
|
# File 'app/controllers/ish_manager/email_actions_controller.rb', line 20
def new
authorize! :new, @new_email_action
end
|
#show ⇒ Object
24
25
26
27
|
# File 'app/controllers/ish_manager/email_actions_controller.rb', line 24
def show
@act = @email_action = Office::EmailAction.find( params[:id] )
authorize! :show, @act
end
|
#update ⇒ Object
def create; update; end def upsert; update; end
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
56
57
58
59
60
|
# File 'app/controllers/ish_manager/email_actions_controller.rb', line 31
def update
if params[:id]
@act = @email_action = Office::EmailAction.find( params[:id] )
else
@act = @email_action = Office::EmailAction.new
end
authorize! :upsert, @act
if params[:email_action][:ties_attributes]
params[:email_action][:ties_attributes].each do |k, v|
if !v[:next_email_action_id].present?
params[:email_action][:ties_attributes].delete( k )
end
if v[:to_delete] == "1"
EActie.find( v[:id] ).delete
params[:email_action][:ties_attributes].delete( k )
end
end
end
flag = @act.update_attributes( params[:email_action].permit! )
if flag
flash[:notice] = 'Success'
redirect_to action: 'index'
else
flash[:alert] = "No luck: #{@act.errors.full_messages.join(', ')}. #{@act.ties.map { |t| t.errors.full_messages.join(', ') }.join(' | ') }"
render action: 'edit'
end
end
|