Hiya RoR gurus, I work at a .NET shop, but I enjoy learning Ruby. So, I wanna prototype some of our product''s screens using Rails (and hopefullly AJAX). One thing I''m not sure about, since I''m a Rails noob, is whether ActiveRecord will get along with our database... So I have two questions: * Can I have ActiveRecord get along with our PascalCase naming conventions? * We ALWAYS have two fields as our primary key: Id and EffectiveYear, which is an integer containing a year and a version, ie 200600000, 200600001, ... This is a strict requirement, so can I get ActiveRecord to do this (easily)? Thanks in advance, ZachZ
Hi, I''m not a guru, but I also work with legacy tables.> * Can I have ActiveRecord get along with our PascalCase naming >conventions?I think so. Mostly anything in rails can be overriden. If your tables'' names are not underscored, you can set_table_name in the models to your PascalCase names. And you can always access your columns'' names through the model using the PascalCase without a hitch.> > * We ALWAYS have two fields as our primary key: Id and >EffectiveYear, which is an integer containing a year and a version, ie >200600000, 200600001, ... This is a strict requirement, so can I get >ActiveRecord to do this (easily)?My partial conclusion is that you cannot specify primary key with two columns in the current rails. My workaround is to create a view that combines the two keys into one key called id, and for any tables that FKs this id, I created a view with a FK alias of the name referencedtable_id just so I don''t need to do overriding in the models. Sinmce you''re just prototyping, this can be quick and effective. good luck! -- Posted with http://DevLists.com. Sign up and save your time!
I can try making few views like you said for a prototype, but we have A LOT of tables, so that would not be optimal in the future! Hmm... Maybe there''s some more ideas out there...?
> I can try making few views like you said for a prototype, but we have > A LOT of tables, so that would not be optimal in the future! Hmm... > Maybe there''s some more ideas out there...?Once you''ve tried on a few views, you could extract some general trends out of your legacy tables and automate the process (write a tool which will generate the rails models with the default overriden for instance). hope this helps Thibaut -- [blog] http://www.dotnetguru2.org/tbarrere -------------- next part -------------- An HTML attachment was scrubbed... URL: http://wrath.rubyonrails.org/pipermail/rails/attachments/20060213/315e8f24/attachment.html
> Once you''ve tried on a few views, you could extract some general trendsout of your legacy tables and automate the process (write a> tool which will generate the rails models with the default overriden forinstance). edit: the tool in question could be ruby+erb, or CodeSmith if you want to do that in c# :) cheers -T -------------- next part -------------- An HTML attachment was scrubbed... URL: http://wrath.rubyonrails.org/pipermail/rails/attachments/20060213/c8cbfcc6/attachment-0001.html