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 . -- Posted via http://www.ruby-forum.com/.
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 On 3/23/06, Oliver P <oliver.pengj@gmail.com> wrote:> > 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 . > > -- > Posted via http://www.ruby-forum.com/. > _______________________________________________ > Rails mailing list > Rails@lists.rubyonrails.org > http://lists.rubyonrails.org/mailman/listinfo/rails >-------------- next part -------------- An HTML attachment was scrubbed... URL: http://wrath.rubyonrails.org/pipermail/rails/attachments/20060323/c777413c/attachment.html
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. > > ChrisThank 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? -- Posted via http://www.ruby-forum.com/.
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 -- Posted via http://www.ruby-forum.com/.