A rant about the Ruby on Rails framework

10:49 am

I was a bit annoyed by the lack of an important feature that the RoR ActiveRecord should have been included since Day One.   ActiveRecord in RoR is an ORM (Object-Relational Mapping) which takes care of the mostly automatic data mapping between the database and your application.

ActiveRecord uses reflection to gather all types of information about your database scheme and builds up the corresponding linkages.

However… except for the relationships between tables????  I make sure that my database tables are properly linked via foreign keys as well as establishing the primary keys and unique indexes.

ActiveRecord is strangely deficient in this area and requires you to repeat your definitions again inside the application layer at the model level.  There’s no reason why this cannot be automatically done.

Bookmark and Share
Uncategorized
Related posts:
  • Nathan
    Exactly, there is no need to be doing any of that at the database level. When you are using rails rake to build your database tables it will build them to be pretty basic, all validation and insertion into the tables are done at the application level.
  • Andrew Cherry
    As I would understand it, and logically speaking, is that Rails doesn't require anything other the most very basic relational database. Foreign key constraints aren't required/supported in certain databases (MySQL until recently for one), and requiring them to derive model relationships would limit the available databases for use with Rails.

    It's also possible that models could at some point be stored in a non-relational form, i.e. a different form of serialization. Again, the possibility of this type of adaptation is removed if you rely on specific features. The minimum is what is currently used.
blog comments powered by Disqus