How to put the model class in module?

I meet a strange problem. I have a table name is application. So I have
to use Application as the model class name. But it reports error. If I
put the model class into my special module and require the file in
controller, it works. But I find that all predefined methods in Active
Record are no longer effective, such as validate and so on.

Can you please give me some idea on this problem? Thanks .

why not just do:

class AppModel < ActiveRecord::Base
set_table_name “application”
end

or, the easiest way, rename your table so it doesn’t conflict with
Rails.

Chris

Chris H. wrote:

why not just do:

class AppModel < ActiveRecord::Base
set_table_name “application”
end

or, the easiest way, rename your table so it doesn’t conflict with
Rails.

Chris

Thank your reply.

But the problem still exist. I have to put the AppModel class in my
special module, otherwise the controller can’t find the new model. It
will report that “uninitialized constant AppModel”. Can you please give
some suggestion?

Oliver P wrote:

Chris H. wrote:

why not just do:

class AppModel < ActiveRecord::Base
set_table_name “application”
end

or, the easiest way, rename your table so it doesn’t conflict with
Rails.

Chris

Thank your reply.

But the problem still exist. I have to put the AppModel class in my
special module, otherwise the controller can’t find the new model. It
will report that “uninitialized constant AppModel”. Can you please give
some suggestion?

hi,

I’m guessing that the controller is now not loading it automatically,
you can tell it to do so using
model :app_model


Agnieszka

I got it. Thank you very much!