Nicolas Blanco
2006-Aug-10 13:11 UTC
[Rails] Newbie : question about Rails naming conventions
Hi, I''m really new to Ruby on Rails and I''m going to use it for my personal webpage. I would also like to use for one of my profesional projects, the problem is that our Database admin has its own conventions that does not respect Rails'' ones. He uses its own conventions for naming tables AND fields names. Is it possible to set up the table name and fields names for a model? The field names that my DBA uses are really not human readable (for example : ARPONA5164 for the field name "title") and I don''t want to use them in my code. I would like to setup them once and after use them like Post.title and not Post.ARPONA5164. -- Posted via http://www.ruby-forum.com/.
Nicolas Blanco
2006-Aug-10 13:57 UTC
[Rails] Re: Newbie : question about Rails naming conventions
Hi again. I''ve just read ActiveRecord::Base "Overwriting default accessors" part on Rails API. Is it a good solution to write this kind of code for each field name : def title=(val) write_attribute(:ARPONA5164, val) end def title read_attribute(:ARPONA5164) end ? Thanks. Nicolas Blanco wrote:> Hi, I''m really new to Ruby on Rails and I''m going to use it for my > personal webpage. > > I would also like to use for one of my profesional projects, the problem > is that our Database admin has its own conventions that does not respect > Rails'' ones. > > He uses its own conventions for naming tables AND fields names. > > Is it possible to set up the table name and fields names for a model? > The field names that my DBA uses are really not human readable (for > example : ARPONA5164 for the field name "title") and I don''t want to use > them in my code. I would like to setup them once and after use them like > Post.title and not Post.ARPONA5164.-- Posted via http://www.ruby-forum.com/.
Jim Lindley
2006-Aug-10 14:28 UTC
[Rails] Newbie : question about Rails naming conventions
On 8/10/06, Nicolas Blanco <slainer68@gmail.com> wrote:> > > Is it possible to set up the table name and fields names for a model? > The field names that my DBA uses are really not human readable (for > example : ARPONA5164 for the field name "title") and I don''t want to use > them in my code. I would like to setup them once and after use them like > Post.title and not Post.ARPONA5164. >Yes, you can alias more readable names. You''ll just need to do some config in your model with Active Record. -------------- next part -------------- An HTML attachment was scrubbed... URL: http://wrath.rubyonrails.org/pipermail/rails/attachments/20060810/cff7eea3/attachment.html