Hi, When I try to run this command I got a table does not exist.>> Vehicule.get_vehicule(123,1123)class Vehicule < ActiveRecord::Base set_table_name "table_a" def self.get_vehicule( inte_no, poas_no) find_by_inte_no_and_poas_no( inte_no, poas_no) end end It looks like if you have a custom method in your model, the "set_table_name" is not taken as the real table name. As soon I rename my model the name of the table(which is not what I want) the get_vehicule worked. I''m on Rails edge. Rémi -- Posted via http://www.ruby-forum.com/. --~--~---------~--~----~------------~-------~--~----~ 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 rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe@googlegroups.com For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
Christian Rishøj
2008-Sep-12 01:58 UTC
Re: Problem with set_table_name and custom method in model
I recall having a similar problem. I believe I got around it by overriding the table_name method on the class, e.g.: class Vehicule < ActiveRecord::Base def self.table_name "table_a" end end Christian On Thu, Sep 11, 2008 at 7:15 PM, Rémi Gagnon <rails-mailing-list-ARtvInVfO7ksV2N9l4h3zg@public.gmane.org> wrote:> > Hi, > > When I try to run this command I got a table does not exist. > >>> Vehicule.get_vehicule(123,1123) > > > class Vehicule < ActiveRecord::Base > > set_table_name "table_a" > > def self.get_vehicule( inte_no, poas_no) > find_by_inte_no_and_poas_no( inte_no, poas_no) > end > end > > It looks like if you have a custom method in your model, the > "set_table_name" is not taken as the real table name. As soon I rename > my model the name of the table(which is not what I want) the > get_vehicule worked. > > I''m on Rails edge. > > Rémi > -- > Posted via http://www.ruby-forum.com/. > > > >--~--~---------~--~----~------------~-------~--~----~ 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 rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe@googlegroups.com For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
Rémi Gagnon
2008-Sep-17 12:34 UTC
Re: Problem with set_table_name and custom method in model
Christian Rishøj wrote:> I recall having a similar problem. I believe I got around it by > overriding the table_name method on the class, e.g.: > > class Vehicule < ActiveRecord::Base > > def self.table_name > "table_a" > end > > end > > Christian > > > On Thu, Sep 11, 2008 at 7:15 PM, R�mi GagnonThanks for the response. But it does not seem to work. I have the same problem. any other ideas? -- Posted via http://www.ruby-forum.com/. --~--~---------~--~----~------------~-------~--~----~ 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 rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe@googlegroups.com For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
Just a guess but maybe it will work if instead of self. you use Vehicle. when defining the method: Vehicule.get_vehicule(...) Pepe On Sep 17, 8:34 am, Rémi Gagnon <rails-mailing-l...-ARtvInVfO7ksV2N9l4h3zg@public.gmane.org> wrote:> Christian Rishøj wrote: > > I recall having a similar problem. I believe I got around it by > > overriding the table_name method on the class, e.g.: > > > class Vehicule < ActiveRecord::Base > > > def self.table_name > > "table_a" > > end > > > end > > > Christian > > > On Thu, Sep 11, 2008 at 7:15 PM, R mi Gagnon > > Thanks for the response. But it does not seem to work. I have the same > problem. > > any other ideas? > -- > Posted viahttp://www.ruby-forum.com/.--~--~---------~--~----~------------~-------~--~----~ 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 rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe@googlegroups.com For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
Rémi Gagnon
2008-Sep-23 15:52 UTC
Re: Problem with set_table_name and custom method in model
pepe wrote:> Just a guess but maybe it will work if instead of self. you use > Vehicle. when defining the method: > > Vehicule.get_vehicule(...) > > Pepe > > On Sep 17, 8:34�am, R�mi Gagnon <rails-mailing-l...@andreas-s.net>I found the problem. When you do a set_table_name you have to put the name with the right case. At least in oracle cause it translates it like : ''select * from "table_a"'' and it should be like this ''select * from "TABLE_A"'' -- Posted via http://www.ruby-forum.com/. --~--~---------~--~----~------------~-------~--~----~ 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 rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe@googlegroups.com For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---