This project is archived and is in readonly mode.
Single Table Inherited model generator
-
Ian Terrell
I like this. I'm constantly forgetting to turn off the migration and the fixture in the regular model generator.
-
Michael Koziarski
- Milestone cleared.
- Assigned user set to Michael Koziarski
This looks good to me, but I think the names should be:
script/generate model_subclass Foo Bar
And the usage should name those things Subclass and Parent
Make those changes, upload the patch and I think we're good to go!
Nice simple enhancement, good work.
-
Fabien Jakimowicz
I renamed it to model_subclass and modified documentation and tests.
Thanks !
-
Repository
- State changed from new to committed
(from [2cb60abfecbad78046b0afde156c72a9ae766cf0]) Add an model_subclass generator.
This generator creates a new model as a subclass of an existing model and the unit test for that model. Lets users avoid having to manually delete the fixtures and migration or remember to pass those arguments.
[#2702 Single Table Inherited model generator state:committed]
Signed-off-by: Michael Koziarski michael@koziarski.com
http://github.com/rails/rails/commit/2cb60abfecbad78046b0afde156c72... -
José Valim
Fabien e Koz,
I'm reworking on generators for GSoC. I'm currently planning to move model_subclass out and add a parent option:
script/generate model Car --parent=Vehicule
The main reason is, everyone can extend the model generator to add new behavior. If we have both model_subclass and model, plugin developers will have to extend both.
When a parent option is given, migration is not generated.
What do you think?
-
Michael Koziarski
Sounds good to me, so long as the result is the same a --parent option
could be just as nice (if not nicer :)) -
José Valim
Koz,
The good think is that you can even use it in scaffold, since it will only delegate to the model generator:
script/generate scaffold Car --parent=Vehicule
It creates everything, except the migration.
And how the results could be even nicer? I'm listening! :)
Finally, do you think we need to add a deprecation warning to model_subclass? In theory, it was not released and it's not on the 2.3 stable as well.
