megorei / carrierwave-tire Goto Github PK
View Code? Open in Web Editor NEWTire (elasticsearch) support for CarrierWave
License: MIT License
Tire (elasticsearch) support for CarrierWave
License: MIT License
I am using Tire gem for persistence and I used this gem to bind with carrierwave. My model looks like this:
class Article
include Tire::Model::Persistence
include Tire::Model::Search
include CarrierWave::Tire
mount_uploader :avatar, AvatarUploader, mount_on: :avatar_filename
end
and my uploader looks like this:
class AvatarUploader < CarrierWave::Uploader::Base
storage :file
def store_dir
"uploads/#{model.class.to_s.underscore}/#{mounted_as}/#{model.id}"
end
end
Now, create/update a record is working fine with uploads and all, but I am getting an error while deleting a file like this:
a = Article.find params[:id]
a.destroy
The error is here:
NameError: undefined local variable or method `image' for #<Article:0x9a28934>
from /usr/local/rvm/gems/ruby-1.9.2-p320@os/gems/activemodel-3.2.13/lib/active_model/attribute_methods.rb:407:in `method_missing'
from /usr/local/rvm/gems/ruby-1.9.2-p320@os/bundler/gems/carrierwave-tire-4604da35b759/lib/carrierwave/tire.rb:46:in `remove_avatar!'
from /usr/local/rvm/gems/ruby-1.9.2-p320@os/gems/activesupport-3.2.13/lib/active_support/callbacks.rb:416:in `_run__127650161__destroy__1037496241__callbacks'
from /usr/local/rvm/gems/ruby-1.9.2-p320@os/gems/activesupport-3.2.13/lib/active_support/callbacks.rb:405:in `__run_callback'
from /usr/local/rvm/gems/ruby-1.9.2-p320@os/gems/activesupport-3.2.13/lib/active_support/callbacks.rb:385:in `_run_destroy_callbacks'
from /usr/local/rvm/gems/ruby-1.9.2-p320@os/gems/activesupport-3.2.13/lib/active_support/callbacks.rb:81:in `run_callbacks'
from /usr/local/rvm/gems/ruby-1.9.2-p320@os/gems/tire-0.5.7/lib/tire/model/persistence/storage.rb:61:in `destroy'
from (irb):3
from /usr/local/rvm/gems/ruby-1.9.2-p320@os/gems/railties-3.2.13/lib/rails/commands/console.rb:47:in `start'
from /usr/local/rvm/gems/ruby-1.9.2-p320@os/gems/railties-3.2.13/lib/rails/commands/console.rb:8:in `start'
from /usr/local/rvm/gems/ruby-1.9.2-p320@os/gems/railties-3.2.13/lib/rails/commands.rb:41:in `<top (required)>'
from script/rails:6:in `require'
from script/rails:6:in `<main>'
I am using commit 4604da3 code of the master branch of the gem.
My Gemfile
gem 'carrierwave-tire', git: "[email protected]:megorei/carrierwave-tire.git"
Gemfile.lock
GIT
remote: [email protected]:megorei/carrierwave-tire.git
revision: 4604da35b7596e2aebe1778c20fca9103043c74b
specs:
carrierwave-tire (0.0.1)
carrierwave
tire
The error references to this line of code in lib/carrierwave/tire.rb:46
41 class_eval <<-RUBY, __FILE__, __LINE__+1
42 def remove_#{column}!
43 super
44 _mounter(:#{column}).remove = true
45 _mounter(:#{column}).write_identifier
46 FileUtils.rm_rf File.dirname(image.file.path) if image.file.present?
47 end
In line 46
, it says undefined variable or method image
. This error happens only in case of destroy.
I am using Tire gem version 0.5.7 and Carrierwave gem version 0.8.0
carrierwave (0.8.0)
tire (0.5.7)
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.