First off, Rails doesn't mutate the ORM into an MVC - rails just makes it easy to generate a Model View and Controller classes based on a database table.If the egg comes before the chicken it is anything but "easy." Rails doesn't generate a model, it generates a file for you to statically type the model. Now, before I started this rant, I was unaware of Alzabo, DBIx::Class's Schema::Loader, or Rose::DB, I'm currently setting up Rose::DB and liking it a lot. - And thanks to the monks with info - These frameworks do what you mentioned, "generate a model ... based on a database table." Rails simply adds getter/setter methods for the table. Big deal. In the rails community they teach DRY like it is a religion, and then they make the assumption that every DB lacks constriants, and that every programmer wishes to treat the DB as if it had the feature set of SQL lite, or MySQL 3.2. Every programmer doesn't -- I don't. Furthermore, rails doesn't generate a a Model, View, or Controller based on a database table, it generates them based on the arguement you give to the generator, wheither or not they exist is your problem. (though again, like most ORMs it can transparently add the getter/setters for the instances at run time)
Secondly, If you don't change the DB, you're free to change the (possibly generated) classes as you see fit, but if you do change a DB table's fields, the model changes automatically with it (via ActiveRecord).You're obviously misguided. ActiveRecord does not change the model to reflect changes in the db, ever. The only thing the model automatically does, is generate </quote> Alright then, change the primary key, change a check constraint, change a foreign key, change a data type. Oh, look, ActiveRecord proves how adaptive it is yet again. In AR if you create a table with an int column, you can rightfully, or wrongfully attempt to insert a string. The following comes from a ruby bot I was writing with a rails interface, my second rails project. Observe:
Yields this: UPDATE channel SET "name" = '#debian-uy', "descr" = 'Debian Uruguay | http://debianuruguay.org | Si quieres pegar código: http://debian-uy.pastebin.com/ | Gran Campaña Pro-Mirror: http://debianuruguay.org/node/129', "population" = 0 WHERE pkid = 3channel.population = 'foo' channel.save
In reply to Re^2: Non-retarded ORMs, and a general ORM discussions.
by EvanCarroll
in thread Non-retarded ORMs, and a general ORM discussions.
by EvanCarroll
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |