Undefined method `all' for MyModel:Module

I am in the middle of upgrading an application which is only at 2.3 to
rails 3.0 (Then to rails 3.1) Iv’e gotten the application to begin
running. And it can load some models. For example in users I can -
Query user.first. But in this model if I call MyModel.all I get a
undefined method. So I’m a bit stuck, and un sure what todo to get it
working.

app/controllers/home_controller.rb:14:in index' actionpack (3.0.10) lib/action_controller/metal/implicit_render.rb: 4:insend_action’
actionpack (3.0.10) lib/abstract_controller/base.rb:150:in
process_action' actionpack (3.0.10) lib/action_controller/metal/rendering.rb:11:inprocess_action’
actionpack (3.0.10) lib/abstract_controller/callbacks.rb:18:in block in process_action' activesupport (3.0.10) lib/active_support/callbacks.rb:451:in_run__3961353178525835648__process_action__2666700228330603719__callbacks’
activesupport (3.0.10) lib/active_support/callbacks.rb:410:in
_run_process_action_callbacks' activesupport (3.0.10) lib/active_support/callbacks.rb:94:inrun_callbacks’
actionpack (3.0.10) lib/abstract_controller/callbacks.rb:17:in
process_action' actionpack (3.0.10) lib/action_controller/metal/rescue.rb:17:inprocess_action’
actionpack (3.0.10) lib/action_controller/metal/instrumentation.rb:
30:in block in process_action' activesupport (3.0.10) lib/active_support/notifications.rb:52:inblock in instrument’
activesupport (3.0.10) lib/active_support/notifications/
instrumenter.rb:21:in instrument' activesupport (3.0.10) lib/active_support/notifications.rb:52:ininstrument’
actionpack (3.0.10) lib/action_controller/metal/instrumentation.rb:
29:in process_action' actionpack (3.0.10) lib/abstract_controller/base.rb:119:inprocess’
actionpack (3.0.10) lib/abstract_controller/rendering.rb:41:in
process' actionpack (3.0.10) lib/action_controller/metal.rb:138:indispatch’
actionpack (3.0.10) lib/action_controller/metal/rack_delegation.rb:
14:in dispatch' actionpack (3.0.10) lib/action_controller/metal.rb:178:inblock in
action’
actionpack (3.0.10) lib/action_dispatch/routing/route_set.rb:62:in
call' actionpack (3.0.10) lib/action_dispatch/routing/route_set.rb:62:indispatch’
actionpack (3.0.10) lib/action_dispatch/routing/route_set.rb:27:in
call' rack-mount (0.6.14) lib/rack/mount/route_set.rb:148:inblock in call’
rack-mount (0.6.14) lib/rack/mount/code_generation.rb:93:in block in recognize' rack-mount (0.6.14) lib/rack/mount/code_generation.rb:68:inoptimized_each’
rack-mount (0.6.14) lib/rack/mount/code_generation.rb:92:in
recognize' rack-mount (0.6.14) lib/rack/mount/route_set.rb:139:incall’
actionpack (3.0.10) lib/action_dispatch/routing/route_set.rb:493:in
call' actionpack (3.0.10) lib/action_dispatch/middleware/ best_standards_support.rb:17:incall’
actionpack (3.0.10) lib/action_dispatch/middleware/head.rb:14:in
call' rack (1.2.4) lib/rack/methodoverride.rb:24:incall’
actionpack (3.0.10) lib/action_dispatch/middleware/params_parser.rb:
21:in call' actionpack (3.0.10) lib/action_dispatch/middleware/flash.rb:182:incall’
actionpack (3.0.10) lib/action_dispatch/middleware/session/
abstract_store.rb:149:in call' actionpack (3.0.10) lib/action_dispatch/middleware/cookies.rb:302:incall’
activerecord (3.0.10) lib/active_record/query_cache.rb:32:in block in call' activerecord (3.0.10) lib/active_record/connection_adapters/abstract/ query_cache.rb:28:incache’
activerecord (3.0.10) lib/active_record/query_cache.rb:12:in cache' activerecord (3.0.10) lib/active_record/query_cache.rb:31:incall’
activerecord (3.0.10) lib/active_record/connection_adapters/abstract/
connection_pool.rb:354:in call' actionpack (3.0.10) lib/action_dispatch/middleware/callbacks.rb:46:inblock in call’
activesupport (3.0.10) lib/active_support/callbacks.rb:416:in
_run_call_callbacks' actionpack (3.0.10) lib/action_dispatch/middleware/callbacks.rb:44:incall’
rack (1.2.4) lib/rack/sendfile.rb:106:in call' actionpack (3.0.10) lib/action_dispatch/middleware/remote_ip.rb:48:incall’
actionpack (3.0.10) lib/action_dispatch/middleware/show_exceptions.rb:
47:in call' railties (3.0.10) lib/rails/rack/logger.rb:13:incall’
rack (1.2.4) lib/rack/runtime.rb:17:in call' activesupport (3.0.10) lib/active_support/cache/strategy/ local_cache.rb:72:incall’
rack (1.2.4) lib/rack/lock.rb:11:in block in call' <internal:prelude>:10:insynchronize’
rack (1.2.4) lib/rack/lock.rb:11:in call' actionpack (3.0.10) lib/action_dispatch/middleware/static.rb:30:incall’
railties (3.0.10) lib/rails/application.rb:168:in call' railties (3.0.10) lib/rails/application.rb:77:inmethod_missing’
railties (3.0.10) lib/rails/rack/log_tailer.rb:14:in call' rack (1.2.4) lib/rack/content_length.rb:13:incall’
rack (1.2.4) lib/rack/handler/webrick.rb:52:in service' /Users/tspore/.rvm/rubies/ruby-1.9.2-p290/lib/ruby/1.9.1/webrick/ httpserver.rb:111:inservice’
/Users/tspore/.rvm/rubies/ruby-1.9.2-p290/lib/ruby/1.9.1/webrick/
httpserver.rb:70:in run' /Users/tspore/.rvm/rubies/ruby-1.9.2-p290/lib/ruby/1.9.1/webrick/ server.rb:183:inblock in start_thread’

Can someone help me here?

On Oct 24, 5:26am, tspore [email protected] wrote:

I am in the middle of upgrading an application which is only at 2.3 to
rails 3.0 (Then to rails 3.1) Iv’e gotten the application to begin
running. And it can load some models. For example in users I can -
Query user.first. But in this model if I call MyModel.all I get a
undefined method. So I’m a bit stuck, and un sure what todo to get it
working.

What is MyModel ? The error implies it’s not actually an active record
class

Fred

On Oct 24, 4:03pm, tspore [email protected] wrote:

Right. MyModel - would be in Theory the AR model, but it seems to be
erring out on the Helper. (Which it also has)
So for some reason I have a few of the upgraded models, which I can’t
run basic querries against. But some which I can.
However, I don’t see anything which would not allow those selected
models to be ran again AR queries.

Is there a module call MyModel that might be shadowing your active
record class ?

Fred

What I’m thinking is that my application is called the same name as
MyModel so in Application i’m loading in module MyModel
But that is calling -
class Application < Rails::Application … end

But I’m not really sure how else to debug this.
Anythoughts?

On Oct 24, 9:09am, Frederick C. [email protected]

Right. MyModel - would be in Theory the AR model, but it seems to be
erring out on the Helper. (Which it also has)
So for some reason I have a few of the upgraded models, which I can’t
run basic querries against. But some which I can.
However, I don’t see anything which would not allow those selected
models to be ran again AR queries.
class MyModel < ActiveRecord::Base

end
module MyModelHelper

end

On Oct 24, 1:55am, Frederick C. [email protected]

On Oct 24, 10:20pm, tspore [email protected]id wrote:

What I’m thinking is that my application is called the same name as
MyModel so in Application i’m loading in module MyModel

ah, if you’re defining

module MyModel
end

somewhere like that then you can’t also have

class MyModel < AR:Base
end

in development mode it will just never load the AR class, in
production it would try and fail (since my model cannot be a class and
a module). You’re going to have to pick non clashing names (the
application name is probably easiest to change)

Fred

Thank you very much for helping me think through this.
Its a old project, where upgrading it is going to be a couple week
process.

On Oct 24, 11:44pm, Frederick C. [email protected]

This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.

| Privacy Policy | Terms of Service | Remote Ruby Jobs