I have two apps that share several models. I created a gem that contains those models. Minus carrierwave functions and devise methods, it works great (commented them out to test). However when I add them back in I get errors:
undefined method mount_uploader
undefined method devise
I was able to get carrierwave partially working by placing this at the top of one of the models,
require "carrierwave"
require "carrierwave/orm/activerecord"
it would allow the file to upload but it wouldn't save it in the uploads folder, just in the temp one, and it would put the tmp hash in the database instead.
here is my gemspec- journalbooks_core.gemspec
# coding: utf-8
lib = File.expand_path('../lib', __FILE__)
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
require 'journalbooks_core/version'
Gem::Specification.new do |spec|
spec.name = "journalbooks_core"
spec.version = JournalbooksCore::VERSION
spec.authors = [NAME]
spec.email = [EMAIL]
spec.description = "Contains the shared models of journalbooks.com and creative-queue.com"
spec.summary = ""
spec.homepage = ""
spec.license = "MIT"
spec.files = `git ls-files`.split($/)
spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
spec.require_paths = ["lib"]
spec.add_development_dependency "bundler", "~> 1.3"
spec.add_development_dependency "rake"
spec.add_dependency "carrierwave", "= 0.9.0"
spec.add_dependency "devise"
end
Here is the journalbooks_core.rb that runs initially
require "journalbooks_core/version"
module JournalbooksCore
require "models/virtual_request"
require "models/creative_user"
require "models/user"
require "models/virtual"
require "models/cov_order"
end
and here is the model I have been trying to get to work
class CreativeUser < ActiveRecord::Base
require "uploaders/avatar_uploader"
require "carrierwave"
require "carrierwave/orm/activerecord"
...
mount_uploader :avatar, AvatarUploader
...
end