chrislloyd / gravtastic Goto Github PK
View Code? Open in Web Editor NEWAdd Gravatars to your Rubies/Rails (and now Javascript)!
Add Gravatars to your Rubies/Rails (and now Javascript)!
I am using Rails 3 and have in my gemfile
gem 'matthuhiggins-foreigner', :require => 'foreigner'
gem 'gravtastic', '~> 2.2.0'
Then when I start my server, I get this error:
$ rails s
/Library/Ruby/Gems/1.8/gems/matthuhiggins-foreigner-0.6.4/lib/foreigner.rb:29:in `on_load': undefined method `config' for nil:NilClass (NoMethodError)
from /Library/Ruby/Gems/1.8/gems/activesupport-3.0.0/lib/active_support/lazy_load_hooks.rb:36:in `instance_eval'
from /Library/Ruby/Gems/1.8/gems/activesupport-3.0.0/lib/active_support/lazy_load_hooks.rb:36:in `execute_hook'
from /Library/Ruby/Gems/1.8/gems/activesupport-3.0.0/lib/active_support/lazy_load_hooks.rb:43:in `run_load_hooks'
from /Library/Ruby/Gems/1.8/gems/activesupport-3.0.0/lib/active_support/lazy_load_hooks.rb:42:in `each'
from /Library/Ruby/Gems/1.8/gems/activesupport-3.0.0/lib/active_support/lazy_load_hooks.rb:42:in `run_load_hooks'
from /Library/Ruby/Gems/1.8/gems/activerecord-3.0.0/lib/active_record/base.rb:1867
from /Library/Ruby/Gems/1.8/gems/gravtastic-2.2.0/lib/gravtastic.rb:89
from /Library/Ruby/Gems/1.8/gems/bundler-1.0.0/lib/bundler/runtime.rb:64:in `require'
from /Library/Ruby/Gems/1.8/gems/bundler-1.0.0/lib/bundler/runtime.rb:64:in `require'
from /Library/Ruby/Gems/1.8/gems/bundler-1.0.0/lib/bundler/runtime.rb:62:in `each'
from /Library/Ruby/Gems/1.8/gems/bundler-1.0.0/lib/bundler/runtime.rb:62:in `require'
from /Library/Ruby/Gems/1.8/gems/bundler-1.0.0/lib/bundler/runtime.rb:51:in `each'
from /Library/Ruby/Gems/1.8/gems/bundler-1.0.0/lib/bundler/runtime.rb:51:in `require'
from /Library/Ruby/Gems/1.8/gems/bundler-1.0.0/lib/bundler.rb:112:in `require'
from /Users/chad/Dropbox/Sites/pc/config/application.rb:7
from /Library/Ruby/Gems/1.8/gems/railties-3.0.0/lib/rails/commands.rb:28:in `require'
from /Library/Ruby/Gems/1.8/gems/railties-3.0.0/lib/rails/commands.rb:28
from /Library/Ruby/Gems/1.8/gems/railties-3.0.0/lib/rails/commands.rb:27:in `tap'
from /Library/Ruby/Gems/1.8/gems/railties-3.0.0/lib/rails/commands.rb:27
from script/rails:6:in `require'
from script/rails:6
The offending line in gravtastic-2.2.0/lib/gravtastic.rb is
ActiveRecord::Base.send(:include, Gravtastic) if defined?(ActiveRecord) # :nodoc:
And in Foreigner is
ActiveRecord::Base.configurations = Rails.application.config.database_configuration
I don't know if Gravtastic or Foreigner is to blame here; if I comment out either from my Gemfile, the server starts up just fine. You can go over to mattuhiggin's foreigner to see the similar post that I left there.
I'd happily help fix it, but I'm new to this whole world of rails and I've never written a plugin, so I may need some guidance.
def url_params_from_hash(hash)
'?' + hash.map do |key, val|
[self.class.gravatar_abbreviations[key.to_sym] || key.to_s, val.to_s ].join('=')
end.sort.join('&')
end
This method of converting hash to url params is pretty naive. It's not going to work with, for instance, :default => 'Sex & Drugs & Rock & Roll'
.
It's not really a problem in real life (so far), but it's possible to
What's your opinion, mr. Lloyd?
It this normal that my site using gravtastic takes almost one hour take effect showing the members' own avatar.
While the default avatar still holds. Thanks
Is the javascript Implemention still works on rails 4? because I'm have trouble using this.
//=require gravtastic
is_gravtastic :filetype => :jpg, :size => 60, :default => "/images/elements/anonymous.jpg"
is this possible? It only works if i type a whole url, which kind of breaks on your local development server
I'm guessing that the Mongoid::Document.included
call overrides this one...? The end result is that Mongoid just breaks completely.
I am trying to see if I can find a way to work around this, but its not going well. I'm guessing this inclusion method works on the older (Rails 2.x) version of Mongoid without issue, but on the current pre-release version (2.0.0.beta.18 for Rails 3.x), it just doesn't. If there isn't a decent workaround for this, perhaps removing it might be best, and relying on a manual call from Mongoid document classes to include Gravtastic
.
I did everything the install says but I get this error...
undefined method `gravatar_url' for nil:NilClass
Extracted source (around line #9):
6: %p.post_body= post.body
7: %span.author
8: by
9: = image_tag @user.gravatar_url
10: = post.author.name
11: %span.published_on
12: on
I just want to perform save actions to user profile image into gravatar space, then it would be nice to have only 1 gem to manipulate pull and get requests to gravatar app.
From the readme:
And wallah! It's exactly the same as with ActiveRecord!
I think you mean to say voila. Unless of course you're referring to "a person in charge of, employed at, or concerned with a particular thing" that is. :-)
gravtastic :size => 200, :default => "#{Rails.root}/public/images/default.png"
results in these sorts of silly URLs:
http://gravatar.com/avatar/1b84085019dc567bfaf60626a508be80.png?d=/Users/chad/Dropbox/Code/pc/public/images/photo.png
I get similarly silly results when trying without the Rails.root, of course.
I want my staging instance to use the photo stored at the staging instance, the dev instance to not need a network connection, etc. How do I do this?
I d like to change the default the default gravatar image, the G logo, is it possible?
When I try to install gravtastic (latest version) (Mac OS X 10.6.2) using RubyGems 1.3.5, the install fails as so:
danbookpro: daniel$ sudo gem install gravtastic
ERROR: While executing gem ... (NoMethodError)
undefined method `include?' for nil:NilClass
But if I try to install a previous version of the gem:
danbookpro: daniel$ sudo gem install gravtastic --version '=2.1.3'
Successfully installed gravtastic-2.1.3
1 gem installed
Installing ri documentation for gravtastic-2.1.3...
Installing RDoc documentation for gravtastic-2.1.3...
???
Latest gem version simply does not work due to this error:
Profile.first.gravatar_url
ArgumentError: wrong number of arguments (1 for 0)
from /Library/Ruby/Gems/1.8/gems/gravtastic-2.1.1/lib/gravtastic.rb:74:in `gravatar_options'
The line below calls gravatar_options with a single argument, which it does not support.
[self.class.gravatar_options(key.to_sym) || key.to_s, CGI::escape(val.to_s) ].join('=')
def gravatar_options
{
:size => 's',
:default => 'd',
:rating => 'r'
}
end
It appears that the :size argument is being ignored in the latest edge rails. It renders all gravatars the same size
Cheers for the plugin. Would be great to receive nil if the user doesn't have an avatar on gravatar, so that we can supply our own default or alternative, rather than just displaying the gravatar default.
if I use image_tag user.gravatar_url(:size => 32, :default => 'mm'), I will get the image tag with
<img src="http://gravatar.com/avatar/13c60e2a5806406b537daa542d3495da.png?d=mm&r=PG&s=32" >
but it should be
<img src="http://gravatar.com/avatar/13c60e2a5806406b537daa542d3495da.png?d=mm&r=PG&s=32">
When gravtastic is used with bundler, I receive this error: undefined method `is_gravtastic' for User(Table doesn't exist):Class (NoMethodError)
The full error log is available at http://irequest.heroku.com
Sometimes it's is_gravtastic!
, and sometimes just is_gravtastic
.
After upgrading to version 2.2.0, I am still unable to get this working with mongo mapper. Suggestions?
/opt/local/lib/ruby/gems/1.8/gems/mongo_mapper-0.6.10/lib/mongo_mapper/dynamic_finder.rb:32:in method_missing':NoMethodError: undefined method
is_gravtastic!' for User:Class
The ampersands in the Gravatar URLs should be encoded as &
instead of just &
. At the moment the unencoded ampersands cause the HTML to fail to validate.
Line 75 should be:
end.sort.join('&')
Couldn't be much simpler to change. Hope this is helpful!
Please support caching the URL into the database.
I would like to have a column where the gravatur_url with standard option is saved and when calling gravatar_url without options it will be returned the value from database, when calling with options, just append the modifators to the string from the database.
Just trying to get gravtastic working today with
Rails 3.0.7
gravtastic (3.1.0)
ruby 1.9.2p180 (2011-02-18 revision 30909) [x86_64-darwin10.6.0]
I have the following model:
class User < ActiveRecord::Base
include Gravtastic
has_gravatar
devise :database_authenticatable, :confirmable,
:recoverable, :rememberable, :trackable, :validatable
.
.
.
end
When I try the following in the console:
u = User.first
u.gravatar_url
I get:
NoMethodError: undefined method merge' for nil:NilClass from /Users/user/.rvm/gems/ruby-1.9.2-p180/gems/activesupport-3.0.7/lib/active_support/whiny_nil.rb:48:in
method_missing'
from /Users/user/.rvm/gems/ruby-1.9.2-p180/gems/gravtastic-3.1.0/lib/gravtastic.rb:77:in gravatar_url' from (irb):2 from /Users/user/.rvm/gems/ruby-1.9.2-p180/gems/railties-3.0.7/lib/rails/commands/console.rb:44:in
start'
from /Users/user/.rvm/gems/ruby-1.9.2-p180/gems/railties-3.0.7/lib/rails/commands/console.rb:8:in start' from /Users/user/.rvm/gems/ruby-1.9.2-p180/gems/railties-3.0.7/lib/rails/commands.rb:23:in
<top (required)>'
from script/rails:6:in require' from script/rails:6:in
I am sure it is something in my setup, so I apologize in advance for taking your time with this, but I am at a loss.
Tom
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.