Class: ServicesController

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

#createObject


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

def create 
  service = Service.initialize_from_omniauth( omniauth_hash )
  
  if current_user.services << service
    current_user.update_profile_with_omniauth( service.info )

    fetch_photo(service) if no_profile_image?

    flash[:notice] = I18n.t 'services.create.success'
  else
    flash[:error] = I18n.t 'services.create.failure'
  end
  redirect_to_origin
end

#destroyObject


43
44
45
46
47
48
# File 'app/controllers/services_controller.rb', line 43

def destroy
  @service = current_user.services.find(params[:id])
  @service.destroy
  flash[:notice] = I18n.t 'services.destroy.success'
  redirect_to services_url
end

#failureObject


37
38
39
40
41
# File 'app/controllers/services_controller.rb', line 37

def failure
  Rails.logger.info  "error in oauth #{params.inspect}"
  flash[:error] = t('services.failure.error')
  redirect_to services_url
end

#indexObject


18
19
20
# File 'app/controllers/services_controller.rb', line 18

def index
  @services = current_user.services
end