0

My rake task can't find a model comes from a gem on a production environement but works on development.

I read this topic a lot of times (and many others) : Rails 3 rake task can't find model in production

But I can't solve the problem.

Rake finds my other classes on app/models without any problem. It miss only 'RapnsNotification' from the gem "rapns". This class is load during the scenario.

This is my task :

require "rubygems"
require "active_record"
require "awesome_print"
require 'rake'
require 'rapns'

task :delete_user => :environment  do |t, args|
  print "Deleting completely user..."
  print Rails.root
  user_id = ENV["id"]
  @user = User.find(user_id) 
  STDOUT.puts "Do you really want to delete #{@user.firstname} #{@user.lastname} (#{@user.email})? (y/n)"
  input = STDIN.gets.strip
  if input == 'y'
    DeleteUserScenario.call!(@user) unless @user.nil?
  else
    print "deleting user stopped"
  end
end

This is the commande I do (if it could help) :

RAILS_ENV=devcenter bundle exec rake delete_user id=111

And this is my error :

rake aborted!
uninitialized constant Notification::RapnsNotification
...bundle/ruby/1.9.1/gems/activerecord-3.2.12/lib/active_record/inheritance.rb:111:in `compute_type'
...bundle/ruby/1.9.1/gems/activerecord-3.2.12/lib/active_record/reflection.rb:172:in `klass'

Thank you in advance.

Community
  • 1
  • 1
brcebn
  • 1,571
  • 1
  • 23
  • 46

0 Answers0