Iam trying to use mini_magick,but after following the git guide i still recieve uninitialized constant. i have another project working just fine using the same syntax.. however must be missing something ..
photo_uploader.rb
class PhotoUploader < CarrierWave::Uploader::Base
include CarrierWave::MiniMagick
def store_dir
"uploads/#{model.class.to_s.underscore}/#{mounted_as}/#{model.id}"
end
def default_url
"photo.jpg"
end
#right orientation
def right_orientation
manipulate! do |img|
img.auto_orient
img
end
end
def filename
"photo.jpg" if original_filename
end
end
user.rb
require 'bcrypt'
require 'carrierwave'
require 'carrierwave/orm/activerecord'
class User < ActiveRecord::Base
belongs_to :pakars
has_many :courses
scoped_search on: [:name1, :name2]
mount_uploader :photo, PhotoUploader
attr_accessor :password, :password_confirmation
def self.authenticate(email, pass)
u=where("email =?", email).first
return nil if u.nil?
return u if BCrypt::Password.new(u.hashed_password) == pass
nil
end
def password=(pass)
self.hashed_password = BCrypt::Password.create(pass)
end
end
Here is the error
uninitialized constant User::PhotoUploader
Rails.root: C:/Users/User/Desktop/Ruby_training/Project/Pakar_my
and yes i already installed the gems
Gemfile
#carrier wave
gem 'carrierwave'
#mini_magick
gem 'mini_magick' , '3.7.0'
I think you need to add carrierwave
to your application.rb
file like this:
require File.expand_path('../boot', __FILE__)
require 'rails/all'
require 'carrierwave'
if defined?(Bundler)
# Bundler stuff
end
Try this may be it's work for you
Or sometime just restart rails server and after it everything worked fine. :)