I''d like to better understand the criticisms I''ve seen of Rails'' ability to handle legacy data. The ones I''m interested in are those based on Rails'' naming conventions for tables. In my experience in large corporate environments programmers / programs don''t access db tables directly. They access views of those tables. And, to my understanding (and I''m not a dba), the name of a view is independent of the underlying tables, and a column in a view does not need to be named the same as the column in the table the view maps to. So I''m wondering... Can Rails be used on a view? Or does AR not support views for some reason? Or is my understanding of the ability of views regarding (re)naming incorrect? Thanks in advance for any help in understanding this. Best regards, Bill -------------- next part -------------- An HTML attachment was scrubbed... URL: http://wrath.rubyonrails.org/pipermail/rails/attachments/20060413/ee63951b/attachment.html
Rails uses the MVC architecture (Model View Controller). The model is what connects to the database, so in your terminology, the model is the view. The model is responsible for communicating with the database and taking care of things such as relationships and validations. If you were wondering 7 Rails can be integrated into some o:her system which uses these "views", I would doubt this is possible although I really can''t say this accurately as I have no clue what system you are referring to. Do not mistake Rails views for what you are referring to as a view. Views in rails are basically templates, what the designer might work with on a large project. I''ve done a few projects in Rails with legacy schemas, I can''t say that does a particularly bad job of this, once the models are written you can forget entirely what kind of a mess the database might be in. On Thu, Apr 13, 2006 at 08:16:28AM -0500, Bill Walton wrote:> I''d like to better understand the criticisms I''ve seen of Rails'' ability to handle legacy data. The ones I''m interested in are those based on Rails'' naming conventions for tables. In my experience in large corporate environments programmers / programs don''t access db tables directly. They access views of those tables. And, to my understanding (and I''m not a dba), the name of a view is independent of the underlying tables, and a column in a view does not need to be named the same as the column in the table the view maps to. So I''m wondering... > > Can Rails be used on a view? Or does AR not support views for some reason? > > Or is my understanding of the ability of views regarding (re)naming incorrect? > > Thanks in advance for any help in understanding this. > > Best regards, > Bill > _______________________________________________ > Rails mailing list > Rails@lists.rubyonrails.org > http://lists.rubyonrails.org/mailman/listinfo/rails-------------- next part -------------- A non-text attachment was scrubbed... Name: not available Type: application/pgp-signature Size: 189 bytes Desc: Digital signature Url : http://wrath.rubyonrails.org/pipermail/rails/attachments/20060413/72352511/attachment-0001.bin
On Thursday 13 April 2006 14:16, Bill Walton wrote:> I''d like to better understand the criticisms I''ve seen of Rails'' ability to > handle legacy data.??The ones I''m interested in are those?based on Rails'' > naming conventions for tables.? In my experience?in large corporate > environments programmers / programs don''t access db tables directly.? They > access views of those tables.? And, to my understanding (and I''m not a > dba), the name of a view is independent of the underlying tables, and a > column in a view does not need to be named the same as the column in the > table the view maps to.? So I''m wondering... > Can Rails be used on a view?? Or does AR not support views for some reason?A DBMS should present views to the world just like tables. There should be no difference at all in using them in Rails or anything else. Any database system that makes you treat views differently is Bad Software, although I''m not aware of any that do. We use PostgreSQL for all new apps we write, and I now frequently make use of views to reshape third-party data into a more suitable format. You have to make rules to tell the view how to map inserts, deletes and updates to the base tables, but once that is done you can use them as tables. Other systems have different ways to make views updateable (IE, act like tables). I suppose a database that does not have updateable views could not be used like you describe, but I''ve not used any myself. If you are switching an app to Rails, you could create a new, Rails-convention based schema, import your old data, and they produce a set of views so that legacy applications can continue to access data in the same way they always have (for the migration period). Obviously, if you want a legacy app and a Rails app accessing the same database, you must make sure you have all the necessary constraints in place so that one app or t''other doesn''t go inserting incomplete/incorrect data because the views are wrong. But that is always an issue with multiple applications hitting one DB. Ashley
On 4/13/06, Bill Walton <bill.walton@charter.net> wrote:> > I''d like to better understand the criticisms I''ve seen of Rails'' ability to > handle legacy data. The ones I''m interested in are those based on Rails'' > naming conventions for tables. In my experience in large corporate > environments programmers / programs don''t access db tables directly. They > access views of those tables. And, to my understanding (and I''m not a dba), > the name of a view is independent of the underlying tables, and a column in > a view does not need to be named the same as the column in the table the > view maps to. So I''m wondering... > > Can Rails be used on a view? Or does AR not support views for some reason? > > Or is my understanding of the ability of views regarding (re)naming > incorrect? > > Thanks in advance for any help in understanding this. >ActiveRecord is happy to work against a view. If you want to update your database as well as read it, you''ll need to make sure your DBMS supports that against views. Don''t worry about table/view names, because it''s trivial to override the defaults. e.g. class Widget < ActiveRecord::Base set_table_name ''crazy_table_name'' end Several of the other ''magic'' names can also be overridden: class WidgetWithLocking < ActiveRecord::Base set_locking_column ''locktastic'' end If you can arrange things so that your tables have a single integer primary key, you''ll be fine. If you can''t, you''ll have an uphill battle. --Wilson.