I am a doctoral researcher in computer science at ETH Zürich.
Feel free to reach out to me through [email protected].
Add avatars to ActiveRecord models
License: MIT License
I am a doctoral researcher in computer science at ETH Zürich.
Feel free to reach out to me through [email protected].
I'm trying to set the avatar of a user in a seed file (as per the instructions at carrierwave's github readme):
File.open(Rails.root.join('app', 'assets', 'images', 'Jurgen.png')) do |f|
user.avatar = f
end
user.save!
I'm getting the following error:
NoMethodError: undefined method `extension_whitelist' for nil:NilClass
/app/vendor/bundle/ruby/2.4.0/gems/avatari-2.0.1/app/uploaders/avatari/avatar_uploader.rb:11:in `extension_whitelist'
/app/vendor/bundle/ruby/2.4.0/gems/carrierwave-1.2.2/lib/carrierwave/uploader/extension_whitelist.rb:40:in `check_extension_whitelist!'
/app/vendor/bundle/ruby/2.4.0/gems/carrierwave-1.2.2/lib/carrierwave/uploader/callbacks.rb:14:in `block in with_callbacks'
/app/vendor/bundle/ruby/2.4.0/gems/carrierwave-1.2.2/lib/carrierwave/uploader/callbacks.rb:14:in `each'
/app/vendor/bundle/ruby/2.4.0/gems/carrierwave-1.2.2/lib/carrierwave/uploader/callbacks.rb:14:in `with_callbacks'
/app/vendor/bundle/ruby/2.4.0/gems/carrierwave-1.2.2/lib/carrierwave/uploader/cache.rb:137:in `cache!'
/app/vendor/bundle/ruby/2.4.0/gems/carrierwave-1.2.2/lib/carrierwave/mounter.rb:44:in `block in cache'
/app/vendor/bundle/ruby/2.4.0/gems/carrierwave-1.2.2/lib/carrierwave/mounter.rb:42:in `map'
/app/vendor/bundle/ruby/2.4.0/gems/carrierwave-1.2.2/lib/carrierwave/mounter.rb:42:in `cache'
/app/vendor/bundle/ruby/2.4.0/gems/carrierwave-1.2.2/lib/carrierwave/mount.rb:146:in `avatar='
/app/vendor/bundle/ruby/2.4.0/gems/carrierwave-1.2.2/lib/carrierwave/orm/activerecord.rb:70:in `avatar='
Using Rails 5.2.0.beta2.
Also, I found I had to add the carrierwave gem in my Gemfile before the avatari gem because of an uninitialized constant error, similar to #2.
Rails (5.2.0.beta2) project fails to load because of constant error.
/app/vendor/bundle/ruby/2.4.0/gems/bootsnap-1.1.5/lib/bootsnap/load_path_cache/core_ext/active_support.rb:49:in `block in load_missing_constant': uninitialized constant Avatari::Railtie::Mozaic (NameError)
This occurs because the Mozaic constant isn't required prior to calling the initializer 'avatari.mozaic'
block in the Railtie. To get around this I added the mozaic gem to my Gemfile before the avatari gem.
Ideally however, you could add a require statement in the Railtie and maybe prefix the constant with a ::
.
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.