Nat14 / Coffeeshop-group-project

Coffee shop study - LEARN Academy group project
0 stars 0 forks source link

facebook avatar not uploading #16

Open complinggirl opened 8 years ago

complinggirl commented 8 years ago

We are having trouble getting facebook images into the User db. Rebecca will look in to it tonight (March 24)

complinggirl commented 8 years ago

class User < ActiveRecord::Base

Include default devise modules. Others available are:

:confirmable, :lockable, :timeoutable and :omniauthable

devise :database_authenticatable, :registerable, :omniauthable, :recoverable, :rememberable, :trackable, :validatable has_attached_file :avatar, :styles => { :medium => "300x300>", :thumb => "100x100#" } validates_attachment_content_type :avatar, :content_type => /\Aimage\/.*\Z/ has_many :usermeetings has_many :meetings, through: :usermeetings

def self.from_omniauth(auth) where(provider: auth.provider, uid: auth.uid).first_or_create do |user| user.provider = auth.provider user.uid = auth.uid user.email = auth.info.email user.avatar_file_name = auth.info.image

url = auth.info.image

  # avatar_url = url.gsub("­http","htt­ps")
  # user.avatar = URI.parse(avatar_url)
end

end

def self.new_with_session(params, session) if session["devise.user_attributes"] new(session["devise.user_attributes"], without_protection: true) do |user| user.attributes = params user.valid? end else super end end

def password_required? super && provider.blank? end

def update_with_password(params, options) if encrypted_passwords.blank? update_attributes(params, options) else super end end

private

def process_uri(uri)
  require 'open-uri'
  require 'open_uri_redirections'
  open(uri, :allow_redirections => :safe) do |r|
    r.base_uri.to_s
  end
end

end

complinggirl commented 8 years ago

This issue is now resolved

complinggirl commented 8 years ago

This issue is resolved in the deveopment app but with the fb development key, we can only observe one account. Furthermore, we cannot test this feature because of problems with routes.