Reputation: 307
I am using the omniauth-facebook gem and it all works perfectly, except the profile picture won't show; instead of showing the picture when I put in the code image_tag current_user.image.to_s
or image_tag current_user.image
it shows text (saying Picture?type=normal, square, large) instead of the picture itself.
omniauth.rb
Rails.application.config.middleware.use OmniAuth::Builder do
provider :developer unless Rails.env.production?
provider :facebook, '166053726877178', 'df9249e9b70ef047e7a9456c7ebf9632',
:image_size => 'square'
end
and user.rb
class User < ActiveRecord::Base
attr_accessible :email, :image, :name, :nickname, :provider, :uid
has_many :pictures
def self.create_with_omniauth(auth)
create! do |user|
user.provider = auth["provider"]
user.uid = auth["uid"]
user.name = auth["info"]["name"]
user.email = auth["info"]["email"]
user.nickname = user.email.split("@").first
user.image = auth["info"]["image"]
end
end
acts_as_voter
end
thing is, with this type of code it worked on a previous app, but it won't work here. thanks in advance
Upvotes: 2
Views: 1585
Reputation: 1548
to get the image of user use these code instead for each kind of facebook profile image
def largeimage
"http://graph.facebook.com/#{self.uid}/picture?type=large"
end
def normalimage
"http://graph.facebook.com/#{self.uid}/picture?type=normal"
end
def smallimage "http://graph.facebook.com/#{self.uid}/picture?type=small" end
in your views
<%= image_tag(current_user.largeimage)%>
and so on
Upvotes: 7