How do I override Ruby's default functionality of not displaying
integer database fields? I have a database table that has a client_id
field that contains an integer that corresponds to the clients table id
field. The database does not have a foreign key set in place. The
client_id field in the table I am searching is just and INT. When I do
a find(:all) on the table, only the text/varchar fields are returned in
the code.
Obviously, I am a newbie to Ruby. I appreciate any down to earth help
you can give me. I want the query I am doing to return the client_id
field value so I can do some comparisons.
How do I override Ruby's default functionality of not displaying
integer database fields? I have a database table that has a client_id
field that contains an integer that corresponds to the clients table id
field. The database does not have a foreign key set in place. The
client_id field in the table I am searching is just and INT. When I do
a find(:all) on the table, only the text/varchar fields are returned in
the code.
There's no reason that it shouldn't return that column, and you should
be able to access it the same as any other attribute:
The scaffold hides columns with the suffix '_id' by default.
There are two solutions...
1. change the name so that it doesn't contain '_id'
2. stop using the scaffold and put the appropriate calls in the
views...