Class: ProfilesController

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

Overview

Copyright © 2010-2011, Diaspora Inc. This file is

licensed under the Affero General Public License version 3 or later.  See
the COPYRIGHT file.

Instance Method Summary (collapse)

Instance Method Details

- (Object) edit



24
25
26
27
28
29
30
31
32
33
34
35
# File 'app/controllers/profiles_controller.rb', line 24

def edit
  @person = current_user.person
  @aspect  = :person_edit
  @profile = @person.profile

  @tags = @profile.tags
  @tags_array = []
  @tags.each do |obj| 
    @tags_array << { :name => ("#"+obj.name),
      :value => ("#"+obj.name)}
    end
end

- (Object) show

this is terrible because we're actually serving up the associated person here; however, this is the effect that we want for now



16
17
18
19
20
21
22
# File 'app/controllers/profiles_controller.rb', line 16

def show
  @person = Person.find_by_guid!(params[:id])

  respond_to do |format|
    format.json { render :json => PersonPresenter.new(@person, current_user) }
  end
end

- (Object) update



37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
# File 'app/controllers/profiles_controller.rb', line 37

def update
  # upload and set new profile photo
  @profile_attrs = profile_params
  
  munge_tag_string

  #checkbox tags wtf
  @profile_attrs[:searchable] ||= false
  @profile_attrs[:nsfw] ||= false

  if params[:photo_id]
    @profile_attrs[:photo] = Photo.where(:author_id => current_user.person_id, :id => params[:photo_id]).first
  end

  if current_user.update_profile(@profile_attrs)
    flash[:notice] = I18n.t 'profiles.update.updated'
  else
    flash[:error] = I18n.t 'profiles.update.failed'
  end

  respond_to do |format|
    format.js { render :nothing => true, :status => 200 }
    format.any {
      flash[:notice] = I18n.t 'profiles.update.updated'
      if current_user.getting_started?
        redirect_to getting_started_path
      else
        redirect_to edit_profile_path
      end
    }
  end
end