-
-
Save houen/1076237 to your computer and use it in GitHub Desktop.
dsfgdsfg
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Loading development environment (Rails 3.0.7) | |
irb: warn: can't alias exit from irb_exit. | |
ruby-1.9.2-p180 :001 > inst = ImageUploader.new | |
=> | |
ruby-1.9.2-p180 :002 > inst.recreate_versions! | |
NoMethodError: undefined method `read' for nil:NilClass | |
from /Users/houen/.rvm/gems/ruby-1.9.2-p180/gems/activesupport-3.0.7/lib/active_support/whiny_nil.rb:48:in `method_missing' | |
from /Users/houen/.rvm/gems/ruby-1.9.2-p180/gems/carrierwave-0.5.5/lib/carrierwave/uploader/cache.rb:73:in `cache_stored_file!' | |
from /Users/houen/.rvm/gems/ruby-1.9.2-p180/gems/carrierwave-0.5.5/lib/carrierwave/uploader/versions.rb:174:in `recreate_versions!' | |
from (irb):2 | |
from /Users/houen/.rvm/gems/ruby-1.9.2-p180/gems/railties-3.0.7/lib/rails/commands/console.rb:44:in `start' | |
from /Users/houen/.rvm/gems/ruby-1.9.2-p180/gems/railties-3.0.7/lib/rails/commands/console.rb:8:in `start' | |
from /Users/houen/.rvm/gems/ruby-1.9.2-p180/gems/railties-3.0.7/lib/rails/commands.rb:23:in `<top (required)>' | |
from script/rails:6:in `require' | |
from script/rails:6:in `<main>' | |
ruby-1.9.2-p180 :003 > |
Of course this means you have to recreate the image versions on a singular level, instead of the fire-and-forget above, but it works...
Thanks for the response houen...
And please forgive me. I'm a bit new to all of this. Where should I add that function to run a one-off of recreate_versions! I seem to get the method error every way I try.
Thanks again...
You can add it to the model that has the associated image. However if you want to do it as a one off, you could always use script/console (script/rails c in Rails 3). I personally made a rake task that did this as opposed to adding it to the model.
Hi hamzakc...
Thanks so much for this. Its perfect info. I will use it tonight.
Take care guys,
Adam.
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Not as far as I know, but the reason is as hamzakc writes. This means you can work around it quiite easily with a function usch as this:
class UserWithImage
def recreate_images
self.image.recreate_versions! if self.image.present?
end