Skip to content

Instantly share code, notes, and snippets.

@ptagell
Created December 2, 2012 05:18
Show Gist options
  • Save ptagell/4187066 to your computer and use it in GitHub Desktop.
Save ptagell/4187066 to your computer and use it in GitHub Desktop.
rake task
Link.all.each do |ym|
begin
ym.image.cache_stored_file!
ym.image.retrieve_from_cache!(ym.image.cache_name)
ym.image.recreate_versions!
ym.save!
end
end
192-168-1-10:tagell tagell$ rake imageresize
rake aborted!
uninitialized constant Link
/Users/tagell/Sites/tagell/lib/tasks/imagesresize.rake:1:in `<top (required)>'
/Users/tagell/.rvm/gems/ruby-1.9.3-p194/gems/railties-3.2.8/lib/rails/engine.rb:425:in `block in load_tasks'
/Users/tagell/.rvm/gems/ruby-1.9.3-p194/gems/railties-3.2.8/lib/rails/engine.rb:425:in `each'
/Users/tagell/.rvm/gems/ruby-1.9.3-p194/gems/railties-3.2.8/lib/rails/engine.rb:425:in `load_tasks'
/Users/tagell/.rvm/gems/ruby-1.9.3-p194/gems/railties-3.2.8/lib/rails/application.rb:145:in `load_tasks'
/Users/tagell/.rvm/gems/ruby-1.9.3-p194/gems/railties-3.2.8/lib/rails/railtie/configurable.rb:30:in `method_missing'
/Users/tagell/Sites/tagell/Rakefile:7:in `<top (required)>'
/Users/tagell/.rvm/gems/ruby-1.9.3-p194/bin/ruby_noexec_wrapper:14:in `eval'
/Users/tagell/.rvm/gems/ruby-1.9.3-p194/bin/ruby_noexec_wrapper:14:in `<main>'
(See full trace by running task with --trace)
@ptagell
Copy link
Author

ptagell commented Dec 2, 2012

Seem to have solved it - using

require 'rake'
task :imageresize => :environment do
Link.all.each do |ym|

begin
  ym.image.cache_stored_file! 
  ym.image.retrieve_from_cache!(ym.image.cache_name) 
  ym.image.recreate_versions! 
  ym.save! 
end

end
end

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment