ruby - Error using Carrierwave in rails -


i have website contains many users , each user have own profile want let them upload there image through carrierwave gem loop following errors first time work carrierwave gem :( :

actionpack (4.2.4) lib/action_dispatch/middleware/debug_exceptions.rb:21:in `call'   web-console (2.2.1) lib/web_console/middleware.rb:39:in `call'   actionpack (4.2.4) lib/action_dispatch/middleware/show_exceptions.rb:30:in `call'   railties (4.2.4) lib/rails/rack/logger.rb:38:in `call_app'   railties (4.2.4) lib/rails/rack/logger.rb:22:in `call'   quiet_assets (1.1.0) lib/quiet_assets.rb:27:in `call_with_quiet_assets'   request_store (1.2.0) lib/request_store/middleware.rb:8:in `call'   actionpack (4.2.4) lib/action_dispatch/middleware/request_id.rb:21:in `call'   rack (1.6.4) lib/rack/methodoverride.rb:22:in `call'   rack (1.6.4) lib/rack/runtime.rb:18:in `call'   rack-timeout (0.3.2) lib/rack/timeout/core.rb:125:in `block in call'   rack-timeout (0.3.2) lib/rack/timeout/support/timeout.rb:19:in `call'   rack-timeout (0.3.2) lib/rack/timeout/support/timeout.rb:19:in `timeout'   rack-timeout (0.3.2) lib/rack/timeout/core.rb:124:in `call'   activesupport (4.2.4) lib/active_support/cache/strategy/local_cache_middleware.rb:28:in `call'   rack (1.6.4) lib/rack/lock.rb:17:in `call'   actionpack (4.2.4) lib/action_dispatch/middleware/static.rb:116:in `call'   rack (1.6.4) lib/rack/sendfile.rb:113:in `call'   railties (4.2.4) lib/rails/engine.rb:518:in `call'   railties (4.2.4) lib/rails/application.rb:165:in `call'   rack (1.6.4) lib/rack/content_length.rb:15:in `call'   puma (2.14.0) lib/puma/server.rb:541:in `handle_request'   puma (2.14.0) lib/puma/server.rb:388:in `process_client'   puma (2.14.0) lib/puma/server.rb:270:in `block in run'   puma (2.14.0) lib/puma/thread_pool.rb:106:in `call'   puma (2.14.0) lib/puma/thread_pool.rb:106:in `block in spawn_thread' 

here carrier wave gem :

class imageuploader < carrierwave::uploader::base   include carrierwave::rmagick    storage :file    # override directory uploaded files stored.   # sensible default uploaders meant mounted:   def store_dir     "uploads/#{model.class.to_s.underscore}/#{mounted_as}/#{model.id}"   end    # create different versions of uploaded files:   version :thumb     process :resize_to_limit => [200, 200]   end    # add white list of extensions allowed uploaded.   # images might use this:   def extension_white_list     %w(jpg jpeg gif png)   end end 

and here profile model :

class profile < activerecord::base   belongs_to :user   belongs_to :country   has_many :education_experiences   has_many :working_experiences   after_create :set_avatar_url    validates :linkedin_url, format: { with: uri.regexp }, if: proc.new { |company| company.linkedin_url.present? }   validates :facebook_url, format: { with: uri.regexp }, if: proc.new { |company| company.facebook_url.present? }   validates :twitter_url, format: { with: uri.regexp }, if: proc.new { |company| company.twitter_url.present? }   validates :google_plus_url, format: { with: uri.regexp }, if: proc.new { |company| company.google_plus_url.present? }   mount_uploader :avatar_url,imageuploader   def set_avatar_url     avatar_url if avatar_url.present?     gravatar_id = digest::md5.hexdigest(user.email.downcase)     gravatar_url = "http://gravatar.com/avatar/#{gravatar_id}.png?s=100"     self.update avatar_url: gravatar_url   end    def as_json(options={})     {         country_id: self.country_id,         job_title: self.job_title,         bio: self.bio,         linkedin_url: self.linkedin_url,         facebook_url: self.facebook_url,         twitter_url: self.twitter_url,         google_plus_url: self.google_plus_url,         avatar_url: self.avatar_url,         education_experience: self.education_experiences,         working_experience: self.working_experiences     }   end end 

you might need restart server after gem instalation.


Comments

Popular posts from this blog

javascript - jQuery: Add class depending on URL in the best way -

caching - How to check if a url path exists in the service worker cache -

Redirect to a HTTPS version using .htaccess -