Class: ProfileFieldsController

Inherits:
ApplicationController show all
Defined in:
app/controllers/profile_fields_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



7
8
9
10
11
12
13
14
15
16
# File 'app/controllers/profile_fields_controller.rb', line 7

def create
  type = secure_profile_field_type || 'ProfileFieldTypes::Custom'
  @profile_field = @profile_field.becomes(type.constantize)
  @profile_field.profileable = @profileable
  @profile_field.label = params[:label] if params[:label].present?
  @profile_field.save if @profile_field.changed?
  respond_to do |format|
    format.js
  end
end

#destroyObject



37
38
39
# File 'app/controllers/profile_fields_controller.rb', line 37

def destroy
  respond_with @profile_field.destroy
end

#updateObject



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

def update
  if current_user == @profile_field.profileable
    current_user.update_last_seen_activity("pflegt sein eigenes Profil", current_user)
  else
    title = @profile_field.profileable.title
    current_user.update_last_seen_activity("bearbeitet ein Profil: #{title}", @profile_field.profileable)
  end
  
  @profile_field = ProfileField.find(params[:id])
  profile_field_class = ProfileField if @profile_field.type.blank?
  profile_field_class ||= ProfileField.possible_types.find { |possible_type| possible_type.to_s == @profile_field.type }
  if profile_field_class.nil?
    raise "security interrupt: '#{@profile_field.type}' is no permitted profileable object type."
  end
  @profile_field = @profile_field.becomes(profile_field_class)
  updated = @profile_field.update_attributes(params[:profile_field])
  respond_with_bip @profile_field
end