Class: ActionsController

Inherits:
ArtfullyOseController show all
Defined in:
app/controllers/actions_controller.rb

Instance Method Summary collapse

Instance Method Details

#createObject

new and edit don’t exist here, explicitly enforcing that actions can’t be just created by a user they need to be applied to something (a person, search results, a list segment)



13
14
15
16
# File 'app/controllers/actions_controller.rb', line 13

def create
  return apply_to_person if params_person_id
  return apply_to_search if params[:search_id] || params[:segment_id]
end

#destroyObject



34
35
36
37
38
39
40
41
42
43
44
# File 'app/controllers/actions_controller.rb', line 34

def destroy
  @person = Person.find params_person_id
  @action = @person.actions.find params[:id]

  if @action.destroyable?
    @action.destroy
  else
    flash[:notice] = "You can't delete that type of action."
  end
  redirect_to_person(@person)
end

#updateObject



18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
# File 'app/controllers/actions_controller.rb', line 18

def update
  @person = Person.find params_person_id

  @action = Action.find params[:id]
  @action.set_params(params[:artfully_action], @person)

  if @action.valid? && @action.save!
    flash[:notice] = "Action has been logged"
    redirect_to_person(@person)
  else
    flash[:alert] = "There was a problem editing your action, please contact support if the problem persists."
    redirect_to :back
  end

end