0
Iamはmini_magickを使用しようとしていますが、gitガイドの後にはまだ初期化されていない定数があります。私は別のプロジェクトがうまく同じ構文を使用して作業してい..しかしここ..初期化されていない定数User :: PhotoUploader
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
はエラーが
で何かが欠けする必要がありますuninitialized constant User::PhotoUploader
Rails.root: C:/Users/User/Desktop/Ruby_training/Project/Pakar_my
はい、既に宝石をインストール済み
私はあなたがこのようなあなたのapplication.rb
ファイルにcarrierwave
を追加する必要があると思うGemfile
#carrier wave
gem 'carrierwave'
#mini_magick
gem 'mini_magick' , '3.7.0'
はい..サーバを再起動すると動作します。Anil Yadav ^^ –