Problem with set_table_name and custom method in model

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

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

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?

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 [email protected]

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 [email protected]

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”’