This project is archived and is in readonly mode.
Default generator for ActiveModel
Reported by Diego Carrion | August 31st, 2009 @ 11:36 PM | in 3.0.2
When generating an scaffold, Rails now requires that custom ORMs define their API, so the controller knows how to call the model. This makes perfectly sense to ORMs that don't implement ActiveModel, like DataMapper, but not for ORMs that do implement ActiveModel, because the coolest part of implementing ActiveModel is that you could just plug the code and it will work with Rails defaults.
I have attached a patch that uses Rails::Generators::ActiveModelDefault in case none generator has been specified for the model, so people implementing ActiveModel dont have to worry about the API definition.
cheers
Comments and changes to this ticket
-
José Valim August 31st, 2009 @ 11:43 PM
- Assigned user set to José Valim
-
José Valim September 1st, 2009 @ 10:08 AM
- Milestone cleared.
Good patch. Just some small changes required:
1) Tests does not pass. The current test fails (ScaffoldControllerGeneratorTest):
def test_error_is_shown_if_orm_does_not_provide_interface
error = capture(:stderr){ run_generator ["User", "--orm=unknown"] } assert_equal "Could not load Unknown::Generators::ActiveModel, skipping controller. " << "Error: no such file to load -- generators/unknown.\n", error
end
It can be removed and replaced by a test that ensures that ORM::Generators::ActiveModel is loaded (instead of Rails::Generators::ActiveModel).
2) ActiveRecord::Generators::ActiveModel can now be removed.
Thanks Carrion!
-
Diego Carrion September 1st, 2009 @ 09:02 PM
My fault, test were not running correctly in my machine.
I fixed the test and removed ActiveRecord::Generators::ActiveModel.
-
José Valim September 8th, 2009 @ 07:22 PM
I need some time to apply it on a fork and add more tests. Showing that no error is raised is not actually testing that an ActiveModel subclass can be loaded.
-
Diego Carrion September 8th, 2009 @ 09:25 PM
The test that tests that the code is loaded is the scaffold test. Before the updates, it tested that the ActiveRecord generator was being loaded but that generator doesnt exists anymore, so tests will fail now unless the default generator is being loaded correctly.
-
José Valim September 8th, 2009 @ 09:27 PM
Exactly, so right now, we don't have any test that ensures that ORM::Generators::ActiveModel is loaded, because ActiveRecord is now using the default Rails::Generators::ActiveModel. In other words, we are just testing the fallback.
-
Repository October 20th, 2009 @ 02:47 AM
(from [1f9d234a6b567e68d97e71da6f19bd126e7f7058]) By default use ActiveModel API in controller generators, unless otherwise specified [#3123 status:resolved] http://github.com/rails/rails/commit/1f9d234a6b567e68d97e71da6f19bd...
-
José Valim November 1st, 2009 @ 12:16 PM
- State changed from new to resolved
-
Jeremy Kemper October 15th, 2010 @ 11:01 PM
- Milestone set to 3.0.2
- Importance changed from to
Create your profile
Help contribute to this project by taking a few moments to create your personal profile. Create your profile »
<h2 style="font-size: 14px">Tickets have moved to Github</h2>
The new ticket tracker is available at <a href="https://github.com/rails/rails/issues">https://github.com/rails/rails/issues</a>
People watching this ticket
Attachments
Tags
Referenced by
- 3123 Default generator for ActiveModel (from [1f9d234a6b567e68d97e71da6f19bd126e7f7058]) By defa...