Possible to use a "database first" approach in ruby on rails?
Would it be possible to create a db schema in a GUI mysql administator an开发者_开发问答d then create (or update) a model based on this schema?
This is what migrations are for. Once you learn the DSL, writing migrations (esp. with the built-in generators) is much easier than fiddling with a GUI to create tables. Check out the migrations guide for detailed info.
ActiveRecord already does a lot automatically based on the database schema, such as adding getters and setters based on columns. I'm not sure what more you're wanting, so I dont know how to help you any more specifically.
Migrations might look confusing on first sight, but once you get used to them migrations work naturally in Rails. If you mistype a name, you just rollback and correct the migration file. Or write another mig that corrects the error in the rare case you used it on the production db.
They give you far more power, especially if your project went through several version stages. You can at any point rollback and migrate to any former state and when you add new columns you can easily set default values or write short ruby scripts that adjusts values or relations.
The OP is asking if rails supports a database first approach, the answer I believe is no. If your familiar with .NET that supports both code and database approaches to app design.
精彩评论