Welcome to the Treehouse Community
Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.
Looking to learn something new?
Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.
Start your free trial
Todd Nestor
10,689 PointsRails 4 import gravatars doesn't work
I have been doing the full Treebook app using Rails 4 and have been able to get everything to work so far, well until now. I can't get the get_gravatars method to work. My git repository is at: https://github.com/toddnestor/hercbook
I added the validation requirements that made paperclip work with my version in the first place but now when I run my get_gravatar rake method I get the following output in my log:
[1m[36mUser Load (31.6ms)[0m [1mSELECT "users".* FROM "users"[0m
Command :: file -b --mime-type '/tmp/571d09921cce1d4d07ff92f0398adc7820140603-7062-8gj0b5'
[paperclip] Content Type Spoof: Filename dbb8c8f66b27ca685778e3b8d0fa58a0 ([]), content type discovered from file command: image/jpeg. See documentation to allow this combination.
[1m[35m (2.0ms)[0m begin transaction
Command :: file -b --mime-type '/tmp/077576a0c9a3b72885df060be034725420140603-7062-1i81x82'
[paperclip] Content Type Spoof: Filename dbb8c8f66b27ca685778e3b8d0fa58a0 ([]), content type discovered from file command: image/jpeg. See documentation to allow this combination.
[1m[36mUser Exists (10.6ms)[0m [1mSELECT 1 AS one FROM "users" WHERE ("users"."profile_name" = 'ziqinhu' AND "users"."id" != 2) LIMIT 1[0m
[1m[35m (2.0ms)[0m rollback transaction
Command :: file -b --mime-type '/tmp/50ee27b8bbcd62cede4096e63e800ea920140603-7062-14eyblw'
[paperclip] Content Type Spoof: Filename cf44b2d76a10908521b6b4b6011d332d ([]), content type discovered from file command: image/jpeg. See documentation to allow this combination.
[1m[36m (1.9ms)[0m [1mbegin transaction[0m
Command :: file -b --mime-type '/tmp/df283aa895854f2a5c3deee7afdfefaa20140603-7062-1p6fwgx'
[paperclip] Content Type Spoof: Filename cf44b2d76a10908521b6b4b6011d332d ([]), content type discovered from file command: image/jpeg. See documentation to allow this combination.
[1m[35mUser Exists (9.2ms)[0m SELECT 1 AS one FROM "users" WHERE ("users"."profile_name" = 'mjnestor' AND "users"."id" != 3) LIMIT 1
[1m[36m (0.9ms)[0m [1mrollback transaction[0m
Command :: file -b --mime-type '/tmp/15086d9a320c2b04ad5a19b27f80353720140603-7062-13z0ozw'
[paperclip] Content Type Spoof: Filename 36020ce10fddc5eb340b69d372cca9fd ([]), content type discovered from file command: image/jpeg. See documentation to allow this combination.
[1m[35m (5.2ms)[0m begin transaction
Command :: file -b --mime-type '/tmp/5f85f718e57fb9437c726b416fbbf73720140603-7062-1us2dr9'
[paperclip] Content Type Spoof: Filename 36020ce10fddc5eb340b69d372cca9fd ([]), content type discovered from file command: image/jpeg. See documentation to allow this combination.
[1m[36mUser Exists (10.9ms)[0m [1mSELECT 1 AS one FROM "users" WHERE ("users"."profile_name" = 'mikenestor' AND "users"."id" != 4) LIMIT 1[0m
[1m[35m (0.4ms)[0m rollback transaction
Command :: file -b --mime-type '/tmp/daf2593b879223ece10adafa83e1bef920140603-7062-1yol99d'
[paperclip] Content Type Spoof: Filename 6d62e190d43e37eedcfc636431119397 ([]), content type discovered from file command: image/jpeg. See documentation to allow this combination.
[1m[36m (2.0ms)[0m [1mbegin transaction[0m
Command :: file -b --mime-type '/tmp/1e73a2525b5c995dd4c824d86efb7d4420140603-7062-gwyf3c'
[paperclip] Content Type Spoof: Filename 6d62e190d43e37eedcfc636431119397 ([]), content type discovered from file command: image/jpeg. See documentation to allow this combination.
[1m[35mUser Exists (11.7ms)[0m SELECT 1 AS one FROM "users" WHERE ("users"."profile_name" = 'sherrinestor' AND "users"."id" != 5) LIMIT 1
[1m[36m (0.8ms)[0m [1mrollback transaction[0m
My get_gravatar method looks like this:
def self.get_gravatars
all.each do |user|
if !user.avatar?
user.avatar = URI.parse(user.gravatar_url)
if user.save
print "."
else
print "x"
end
end
end
end
I modified it so I could see in the console if it is working or not.
My gravatars.rake file looks like this:
desc "Import avatars from a user's gravatar URL"
task :import_avatars => :environment do
puts "Importing avatars from Gravatar"
User.get_gravatars
puts "\nAvatars updated"
end
Any help would be appreciated. As this is a non-critical part of the Treebook app I am going to move on to the next steps for now and come back to this a little later, unless someone can help me out then I will fix it sooner :)