Forum: Ruby on Rails how to put the model class in module?

Announcement (2017-05-07): www.ruby-forum.com is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see rubyonrails.org/community and ruby-lang.org/en/community for other Rails- und Ruby-related community platforms.
Fe38faa93e1ba0c6694264d0b2701d01?d=identicon&s=25 Oliver P (Guest)
on 2006-03-23 17:00
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 .
A2c85dc5ee81b12e3cc0a6522e8d079d?d=identicon&s=25 Chris Hall (Guest)
on 2006-03-23 17:07
(Received via mailing list)
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
Fe38faa93e1ba0c6694264d0b2701d01?d=identicon&s=25 Oliver P (Guest)
on 2006-03-24 18:15
Chris Hall 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?
5b132632f47e8c7e2a83157cef4649c8?d=identicon&s=25 Agnieszka Figiel (agnessa)
on 2006-03-24 18:19
Oliver P wrote:
> Chris Hall 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
Fe38faa93e1ba0c6694264d0b2701d01?d=identicon&s=25 Oliver P (Guest)
on 2006-03-24 20:01
I got it. Thank you very much!
This topic is locked and can not be replied to.