2 The extension_model generator creates stubs for a new model for an
5 The generator takes the extension name and a model name as its arguments.
6 The model name may be given in CamelCase or under_score and should not be
9 As additional parameters, the generator will take attribute pairs
10 described by name and type. These attributes will be used to prepopulate
11 the migration to create the table for the model and give you a set of
12 predefined fixtures. You don't have to think up all attributes up front,
13 but it's a good idea of adding just the baseline of what's needed to start
14 really working with the resource.
16 The generator creates a model class in
17 vendor/extensions/extension_name/app/models, a test suite in
18 vendor/extensions/extension_name/test/unit, test fixtures in
19 vendor/extensions/extension_name/test/fixtures/singular_name.yml, and a
20 migration in vendor/extensions/extension_name/db/migrate.
23 ./script/generate extension_model MyExt account
25 This will create an Account model:
27 Model: vendor/extensions/my_ext/app/models/account.rb
28 Test: vendor/extensions/my_ext/test/unit/account_test.rb
29 Fixtures: vendor/extensions/my_ext/test/fixtures/accounts.yml
30 Migration: vendor/extensions/my_ext/db/migrate/XXX_add_accounts.rb
32 ./script/generate extension_model MyExt post title:string body:text
34 Creates post model with predefined attributes.