Model in subfolder, not missing constant error

Hi all,

I’m using the latest rails 2.3.5 and put some models in subfolders like
this:

models/my/details/texts.rb
models/my/details/attributes.rb

The models themselves are defined like this:

class My::Details::Texts < ActiveRecord::Base

class My::Details::Attributes < ActiveRecord::Base

In development mode (using webrick), everything works fine. But in
production mode (using thin), I get these errors:

A ArgumentError occurred in attributes#show:
My::Details is not missing constant Attributes!
/var/lib/gems/1.8/gems/activesupport-2.3.5/lib/active_support/dependencies.rb:417:in
`load_missing_constant’

A ArgumentError occurred in attributes#show:
My::Details is not missing constant Texts!
/var/lib/gems/1.8/gems/activesupport-2.3.5/lib/active_support/dependencies.rb:417:in
`load_missing_constant’

So I wonder if it’s okay to place models in subfolders at all? If yes,
why does this error occur and how to fix it? :slight_smile:

Thanks,
Corin

You received this message because you are subscribed to the Google
Groups “Ruby on Rails: Talk” group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to
[email protected].
For more options, visit this group at
http://groups.google.com/group/rubyonrails-talk?hl=en.

On Jan 2, 8:21 pm, Corin [email protected] wrote:

My::Details is not missing constant Attributes!
/var/lib/gems/1.8/gems/activesupport-2.3.5/lib/active_support/dependencies. rb:417:in `load_missing_constant’

A ArgumentError occurred in attributes#show:
My::Details is not missing constant Texts!
/var/lib/gems/1.8/gems/activesupport-2.3.5/lib/active_support/dependencies. rb:417:in `load_missing_constant’

So I wonder if it’s okay to place models in subfolders at all? If yes, why does this error occur and how to fix it? :slight_smile:

Historically, models in subfolders have caused problems, but they
should work now. Can you post a complete stack trace for either of
these errors?

–Matt J.

You received this message because you are subscribed to the Google
Groups “Ruby on Rails: Talk” group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to
[email protected].
For more options, visit this group at
http://groups.google.com/group/rubyonrails-talk?hl=en.

On Jan 3, 5:33 pm, Matt J. [email protected] wrote:

Historically, models in subfolders have caused problems, but they
should work now. Can you post a complete stack trace for either of
these errors?

–Matt J.

Hi Matt,

here’s the full backtrace:

/var/lib/gems/1.8/gems/activesupport-2.3.5/lib/active_support/
dependencies.rb:417:in load_missing_constant' /var/lib/gems/1.8/gems/activesupport-2.3.5/lib/active_support/ dependencies.rb:80:in const_missing’
/var/lib/gems/1.8/gems/activesupport-2.3.5/lib/active_support/
dependencies.rb:98:in send' /var/lib/gems/1.8/gems/activesupport-2.3.5/lib/active_support/ dependencies.rb:98:in const_missing’
[RAILS_ROOT]/app/controllers/my/details/texts_controller.rb:28:in
find_user' /var/lib/gems/1.8/gems/activesupport-2.3.5/lib/active_support/ callbacks.rb:178:in send’
/var/lib/gems/1.8/gems/activesupport-2.3.5/lib/active_support/
callbacks.rb:178:in evaluate_method' /var/lib/gems/1.8/gems/activesupport-2.3.5/lib/active_support/ callbacks.rb:166:in call’
/var/lib/gems/1.8/gems/actionpack-2.3.5/lib/action_controller/
filters.rb:225:in call' /var/lib/gems/1.8/gems/actionpack-2.3.5/lib/action_controller/ filters.rb:629:in run_before_filters’
/var/lib/gems/1.8/gems/actionpack-2.3.5/lib/action_controller/
filters.rb:615:in call_filters' /var/lib/gems/1.8/gems/actionpack-2.3.5/lib/action_controller/ filters.rb:610:in perform_action_without_benchmark’
/var/lib/gems/1.8/gems/actionpack-2.3.5/lib/action_controller/
benchmarking.rb:68:in perform_action_without_rescue' /var/lib/gems/1.8/gems/activesupport-2.3.5/lib/active_support/ core_ext/benchmark.rb:17:in ms’
/usr/lib/ruby/1.8/benchmark.rb:308:in realtime' /var/lib/gems/1.8/gems/activesupport-2.3.5/lib/active_support/ core_ext/benchmark.rb:17:in ms’
/var/lib/gems/1.8/gems/actionpack-2.3.5/lib/action_controller/
benchmarking.rb:68:in perform_action_without_rescue' /var/lib/gems/1.8/gems/actionpack-2.3.5/lib/action_controller/ rescue.rb:160:in perform_action_without_flash’
/var/lib/gems/1.8/gems/actionpack-2.3.5/lib/action_controller/
flash.rb:146:in perform_action' /var/lib/gems/1.8/gems/actionpack-2.3.5/lib/action_controller/ base.rb:532:in send’
/var/lib/gems/1.8/gems/actionpack-2.3.5/lib/action_controller/
base.rb:532:in process_without_filters' /var/lib/gems/1.8/gems/actionpack-2.3.5/lib/action_controller/ filters.rb:606:in sass_old_process’
/var/lib/gems/1.8/gems/haml-2.2.16/lib/sass/plugin/rails.rb:19:in
process' /var/lib/gems/1.8/gems/actionpack-2.3.5/lib/action_controller/ base.rb:391:in process’
/var/lib/gems/1.8/gems/actionpack-2.3.5/lib/action_controller/
base.rb:386:in call' /var/lib/gems/1.8/gems/actionpack-2.3.5/lib/action_controller/ routing/route_set.rb:437:in call’
/var/lib/gems/1.8/gems/actionpack-2.3.5/lib/action_controller/
dispatcher.rb:87:in dispatch' /var/lib/gems/1.8/gems/actionpack-2.3.5/lib/action_controller/ dispatcher.rb:121:in _call’
/var/lib/gems/1.8/gems/actionpack-2.3.5/lib/action_controller/
dispatcher.rb:130:in build_middleware_stack' /var/lib/gems/1.8/gems/activerecord-2.3.5/lib/active_record/ query_cache.rb:29:in call’
/var/lib/gems/1.8/gems/activerecord-2.3.5/lib/active_record/
query_cache.rb:29:in call' /var/lib/gems/1.8/gems/activerecord-2.3.5/lib/active_record/ connection_adapters/abstract/query_cache.rb:34:in cache’
/var/lib/gems/1.8/gems/activerecord-2.3.5/lib/active_record/
query_cache.rb:9:in cache' /var/lib/gems/1.8/gems/activerecord-2.3.5/lib/active_record/ query_cache.rb:28:in call’
/var/lib/gems/1.8/gems/activerecord-2.3.5/lib/active_record/
connection_adapters/abstract/connection_pool.rb:361:in call' /var/lib/gems/1.8/gems/actionpack-2.3.5/lib/action_controller/ string_coercion.rb:25:in call’
/var/lib/gems/1.8/gems/rack-1.0.1/lib/rack/head.rb:9:in call' /var/lib/gems/1.8/gems/rack-1.0.1/lib/rack/methodoverride.rb:24:in call’
/var/lib/gems/1.8/gems/actionpack-2.3.5/lib/action_controller/
params_parser.rb:15:in call' /var/lib/gems/1.8/gems/actionpack-2.3.5/lib/action_controller/ session/abstract_store.rb:122:in call’
/var/lib/gems/1.8/gems/actionpack-2.3.5/lib/action_controller/
failsafe.rb:26:in call' /var/lib/gems/1.8/gems/rack-1.0.1/lib/rack/lock.rb:11:in call’
/var/lib/gems/1.8/gems/rack-1.0.1/lib/rack/lock.rb:11:in
synchronize' /var/lib/gems/1.8/gems/rack-1.0.1/lib/rack/lock.rb:11:in call’
/var/lib/gems/1.8/gems/actionpack-2.3.5/lib/action_controller/
dispatcher.rb:106:in call' /var/lib/gems/1.8/gems/thin-1.2.5/lib/rack/adapter/rails.rb:74:in call’
/var/lib/gems/1.8/gems/thin-1.2.5/lib/thin/connection.rb:76:in
pre_process' /var/lib/gems/1.8/gems/thin-1.2.5/lib/thin/connection.rb:74:in catch’
/var/lib/gems/1.8/gems/thin-1.2.5/lib/thin/connection.rb:74:in
pre_process' /var/lib/gems/1.8/gems/thin-1.2.5/lib/thin/connection.rb:57:in process’
/var/lib/gems/1.8/gems/thin-1.2.5/lib/thin/connection.rb:42:in
receive_data' /var/lib/gems/1.8/gems/eventmachine-0.12.10/lib/eventmachine.rb: 256:in run_machine’
/var/lib/gems/1.8/gems/eventmachine-0.12.10/lib/eventmachine.rb:
256:in run' /var/lib/gems/1.8/gems/thin-1.2.5/lib/thin/backends/base.rb:57:in start’
/var/lib/gems/1.8/gems/thin-1.2.5/lib/thin/server.rb:156:in start' /var/lib/gems/1.8/gems/thin-1.2.5/lib/thin/controllers/controller.rb: 80:in start’
/var/lib/gems/1.8/gems/thin-1.2.5/lib/thin/runner.rb:177:in send' /var/lib/gems/1.8/gems/thin-1.2.5/lib/thin/runner.rb:177:in run_command’
/var/lib/gems/1.8/gems/thin-1.2.5/lib/thin/runner.rb:143:in run!' /var/lib/gems/1.8/gems/thin-1.2.5/bin/thin:6 /usr/bin/thin:19:in load’
/usr/bin/thin:19

Corin

You received this message because you are subscribed to the Google
Groups “Ruby on Rails: Talk” group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to
[email protected].
For more options, visit this group at
http://groups.google.com/group/rubyonrails-talk?hl=en.

Same backtrace without line breaks (hopefully):

/var/lib/gems/1.8/gems/activesupport-2.3.5/lib/active_support/dependencies.rb:417:in
`load_missing_constant’

/var/lib/gems/1.8/gems/activesupport-2.3.5/lib/active_support/dependencies.rb:80:in
`const_missing’

/var/lib/gems/1.8/gems/activesupport-2.3.5/lib/active_support/dependencies.rb:98:in
`send’

/var/lib/gems/1.8/gems/activesupport-2.3.5/lib/active_support/dependencies.rb:98:in
const_missing' [RAILS_ROOT]/app/controllers/my/details/texts_controller.rb:28:in find_user’

/var/lib/gems/1.8/gems/activesupport-2.3.5/lib/active_support/callbacks.rb:178:in
`send’

/var/lib/gems/1.8/gems/activesupport-2.3.5/lib/active_support/callbacks.rb:178:in
`evaluate_method’

/var/lib/gems/1.8/gems/activesupport-2.3.5/lib/active_support/callbacks.rb:166:in
`call’

/var/lib/gems/1.8/gems/actionpack-2.3.5/lib/action_controller/filters.rb:225:in
`call’

/var/lib/gems/1.8/gems/actionpack-2.3.5/lib/action_controller/filters.rb:629:in
`run_before_filters’

/var/lib/gems/1.8/gems/actionpack-2.3.5/lib/action_controller/filters.rb:615:in
`call_filters’

/var/lib/gems/1.8/gems/actionpack-2.3.5/lib/action_controller/filters.rb:610:in
`perform_action_without_benchmark’

/var/lib/gems/1.8/gems/actionpack-2.3.5/lib/action_controller/benchmarking.rb:68:in
`perform_action_without_rescue’

/var/lib/gems/1.8/gems/activesupport-2.3.5/lib/active_support/core_ext/benchmark.rb:17:in
ms' /usr/lib/ruby/1.8/benchmark.rb:308:in realtime’

/var/lib/gems/1.8/gems/activesupport-2.3.5/lib/active_support/core_ext/benchmark.rb:17:in
`ms’

/var/lib/gems/1.8/gems/actionpack-2.3.5/lib/action_controller/benchmarking.rb:68:in
`perform_action_without_rescue’

/var/lib/gems/1.8/gems/actionpack-2.3.5/lib/action_controller/rescue.rb:160:in
`perform_action_without_flash’

/var/lib/gems/1.8/gems/actionpack-2.3.5/lib/action_controller/flash.rb:146:in
`perform_action’

/var/lib/gems/1.8/gems/actionpack-2.3.5/lib/action_controller/base.rb:532:in
`send’

/var/lib/gems/1.8/gems/actionpack-2.3.5/lib/action_controller/base.rb:532:in
`process_without_filters’

/var/lib/gems/1.8/gems/actionpack-2.3.5/lib/action_controller/filters.rb:606:in
sass_old_process' /var/lib/gems/1.8/gems/haml-2.2.16/lib/sass/plugin/rails.rb:19:in process’

/var/lib/gems/1.8/gems/actionpack-2.3.5/lib/action_controller/base.rb:391:in
`process’

/var/lib/gems/1.8/gems/actionpack-2.3.5/lib/action_controller/base.rb:386:in
`call’

/var/lib/gems/1.8/gems/actionpack-2.3.5/lib/action_controller/routing/route_set.rb:437:in
`call’

/var/lib/gems/1.8/gems/actionpack-2.3.5/lib/action_controller/dispatcher.rb:87:in
`dispatch’

/var/lib/gems/1.8/gems/actionpack-2.3.5/lib/action_controller/dispatcher.rb:121:in
`_call’

/var/lib/gems/1.8/gems/actionpack-2.3.5/lib/action_controller/dispatcher.rb:130:in
`build_middleware_stack’

/var/lib/gems/1.8/gems/activerecord-2.3.5/lib/active_record/query_cache.rb:29:in
`call’

/var/lib/gems/1.8/gems/activerecord-2.3.5/lib/active_record/query_cache.rb:29:in
`call’

/var/lib/gems/1.8/gems/activerecord-2.3.5/lib/active_record/connection_adapters/abstract/query_cache.rb:34:in
`cache’

/var/lib/gems/1.8/gems/activerecord-2.3.5/lib/active_record/query_cache.rb:9:in
`cache’

/var/lib/gems/1.8/gems/activerecord-2.3.5/lib/active_record/query_cache.rb:28:in
`call’

/var/lib/gems/1.8/gems/activerecord-2.3.5/lib/active_record/connection_adapters/abstract/connection_pool.rb:361:in
`call’

/var/lib/gems/1.8/gems/actionpack-2.3.5/lib/action_controller/string_coercion.rb:25:in
call' /var/lib/gems/1.8/gems/rack-1.0.1/lib/rack/head.rb:9:in call’
/var/lib/gems/1.8/gems/rack-1.0.1/lib/rack/methodoverride.rb:24:in
`call’

/var/lib/gems/1.8/gems/actionpack-2.3.5/lib/action_controller/params_parser.rb:15:in
`call’

/var/lib/gems/1.8/gems/actionpack-2.3.5/lib/action_controller/session/abstract_store.rb:122:in
`call’

/var/lib/gems/1.8/gems/actionpack-2.3.5/lib/action_controller/failsafe.rb:26:in
call' /var/lib/gems/1.8/gems/rack-1.0.1/lib/rack/lock.rb:11:in call’
/var/lib/gems/1.8/gems/rack-1.0.1/lib/rack/lock.rb:11:in synchronize' /var/lib/gems/1.8/gems/rack-1.0.1/lib/rack/lock.rb:11:in call’

/var/lib/gems/1.8/gems/actionpack-2.3.5/lib/action_controller/dispatcher.rb:106:in
call' /var/lib/gems/1.8/gems/thin-1.2.5/lib/rack/adapter/rails.rb:74:in call’
/var/lib/gems/1.8/gems/thin-1.2.5/lib/thin/connection.rb:76:in
pre_process' /var/lib/gems/1.8/gems/thin-1.2.5/lib/thin/connection.rb:74:in catch’
/var/lib/gems/1.8/gems/thin-1.2.5/lib/thin/connection.rb:74:in
pre_process' /var/lib/gems/1.8/gems/thin-1.2.5/lib/thin/connection.rb:57:in process’
/var/lib/gems/1.8/gems/thin-1.2.5/lib/thin/connection.rb:42:in
receive_data' /var/lib/gems/1.8/gems/eventmachine-0.12.10/lib/eventmachine.rb:256:in run_machine’
/var/lib/gems/1.8/gems/eventmachine-0.12.10/lib/eventmachine.rb:256:in
run' /var/lib/gems/1.8/gems/thin-1.2.5/lib/thin/backends/base.rb:57:in start’
/var/lib/gems/1.8/gems/thin-1.2.5/lib/thin/server.rb:156:in `start’

/var/lib/gems/1.8/gems/thin-1.2.5/lib/thin/controllers/controller.rb:80:in
start' /var/lib/gems/1.8/gems/thin-1.2.5/lib/thin/runner.rb:177:in send’
/var/lib/gems/1.8/gems/thin-1.2.5/lib/thin/runner.rb:177:in
run_command' /var/lib/gems/1.8/gems/thin-1.2.5/lib/thin/runner.rb:143:in run!’
/var/lib/gems/1.8/gems/thin-1.2.5/bin/thin:6
/usr/bin/thin:19:in `load’
/usr/bin/thin:19

On 03.01.2010 21:46, wakathane wrote:

[RAILS_ROOT]/app/controllers/my/details/texts_controller.rb:28:in
filters.rb:629:in run_before_filters' core_ext/benchmark.rb:17:in ms’
/var/lib/gems/1.8/gems/actionpack-2.3.5/lib/action_controller/
dispatcher.rb:87:in dispatch' /var/lib/gems/1.8/gems/activerecord-2.3.5/lib/active_record/ /var/lib/gems/1.8/gems/actionpack-2.3.5/lib/action_controller/ dispatcher.rb:106:in call’
/var/lib/gems/1.8/gems/thin-1.2.5/lib/thin/connection.rb:42:in
/var/lib/gems/1.8/gems/thin-1.2.5/lib/thin/runner.rb:177:in `send’

You received this message because you are subscribed to the Google G. “Ruby on Rails: Talk” group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to [email protected].
For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.

You received this message because you are subscribed to the Google
Groups “Ruby on Rails: Talk” group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to
[email protected].
For more options, visit this group at
http://groups.google.com/group/rubyonrails-talk?hl=en.