Hi, I''m using Rails with DB2 Database. The tables in the database are NOT rails conventions, and there is no ''id'' column too in the tables. Hnece in the Model i''m setting the table name like this ModelEmployee.set_table_name "employee" Now if i try to print the colulmn names, it does not print anything, i have tried to print the column name as below, but its not printing anything. ModelEmployee.set_table_name "employee" puts ModelEmployee.column_names puts ModelEmployee.content_columns Hence if we are using Legecy Database, how should we access the column names of the corresponding model? Thanks. Dinesh -- 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-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
maybe like this : class Employee < ActiveRecord::Base set_table_name "employee" end the in irb: puts Employee.column_names maybe show us the table structure, would be helpfull to see it, concering primary key setup and the like ... --~--~---------~--~----~------------~-------~--~----~ 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-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
Dinesh wrote:> I''m using Rails with DB2 Database. The tables in the database are NOT > rails conventions, and there is no ''id'' column too in the tables.Can you use the SQL VIEW statement to rename things to Rails''s liking? VIEW is very powerful, and could fix the "problem" at its source. In a multi-layered system like a website stack, I always seek to solve the problem in the most convenient (and efficient) layer... -- Phlip --~--~---------~--~----~------------~-------~--~----~ 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-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
Phlip wrote:> Dinesh wrote: > >> I''m using Rails with DB2 Database. The tables in the database are NOT >> rails conventions, and there is no ''id'' column too in the tables. > > Can you use the SQL VIEW statement to rename things to Rails''s liking? > VIEW is very powerful, and could fix the "problem" at its source. > > In a multi-layered system like a website stack, I always seek to solve > the problem in the most convenient (and efficient) layer... > > -- > Phlip<shamelessPlug> You could use the DrySQL Ruby plugin: http://drysql.rubyforge.org It will automatically identify all your keys, and generate all the associations and validations for your ActiveRecord data class, even if you do not follow the ActiveRecord naming conventions. All you need to do is name your table according to ActiveRecord naming conventions OR call set_table_name in your class definition, and DrySQL handles the rest. </shamelessPlug> -- 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-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---