makandra / active_type

Make any Ruby object quack like ActiveRecord
MIT License
1.09k stars 74 forks source link

Can't find ActiveType::Object from rake tasks of Rails #75

Closed kyanagi closed 7 years ago

kyanagi commented 7 years ago

This problem is reproduced with active_type 0.6.2, not with 0.6.1.

% ruby -v
ruby 2.4.0p0 (2016-12-24 revision 57164) [x86_64-darwin16]

% rails -v
Rails 5.0.1

% rails new demo && cd demo
% echo "gem 'active_type'" >> Gemfile
% bundle install
% echo 'class X < ActiveType::Object; end' > app/models/x.rb
% echo 'task foo: [:environment] do; X; end' > lib/tasks/foo.rake
% bundle exec rake foo
/Users/ani/.rbenv/versions/2.4.0/lib/ruby/gems/2.4.0/gems/activesupport-5.0.1/lib/active_support/xml_mini.rb:51: warning: constant ::Fixnum is deprecated
/Users/ani/.rbenv/versions/2.4.0/lib/ruby/gems/2.4.0/gems/activesupport-5.0.1/lib/active_support/xml_mini.rb:52: warning: constant ::Bignum is deprecated
/Users/ani/.rbenv/versions/2.4.0/lib/ruby/gems/2.4.0/gems/activesupport-5.0.1/lib/active_support/core_ext/numeric/conversions.rb:138: warning: constant ::Fixnum is deprecated
rake aborted!
NameError: uninitialized constant ActiveType::Object
/private/var/tmp/demo/app/models/x.rb:1:in `<top (required)>'
/private/var/tmp/demo/lib/tasks/foo.rake:1:in `block in <top (required)>'
/Users/ani/.rbenv/versions/2.4.0/bin/bundle:22:in `load'
/Users/ani/.rbenv/versions/2.4.0/bin/bundle:22:in `<main>'
Tasks: TOP => foo
(See full trace by running task with --trace)
kratob commented 7 years ago

It's not actually connected to Rake. In 0.6.2, within a Rails app, using ActiveType::Object without first using ActiveRecord::Base will produce this error. Working on a fix.

kratob commented 7 years ago

I've just released 0.6.3, which should fix this issue. Thanks for reporting!