Sha256: ead02a83f73c28228c75ed4296c4f7b9d034205302cd2b3e963737e4f83f5e2e
Contents?: true
Size: 1.73 KB
Versions: 17
Compression:
Stored size: 1.73 KB
Contents
Description: The model generator creates stubs for a new model, corresponding controller and it's views. The generator takes a model name as its argument. The model name may be given in CamelCase or under_score and should not be suffixed with anything. As additional parameters, the generator will take attribute pairs described by name and type. These attributes will be used to prepopulate the migration to create the table for the model and give you a set of predefined fixture. You don't have to think up all attributes up front, but it's a good idea of adding just the baseline of what's needed to start really working with the resource. The generator creates a model class in app/models, a test suite in test/unit and test fixtures in test/fixtures/singular_name.yml. The generator creates a controller class in app/controllers with view templates in app/views/controller_name, a helper class in app/helpers, and a functional test suite in test/functional. Examples: ./script/generate hobo_model_resource account This will create an Account model: Model: app/models/account.rb Controller: app/controllers/accounts_controller.rb Helper: app/helpers/accounts_helper.rb Views: app/views/accounts ViewHints: app/viewhints/account_hints.rb Test: test/unit/account_test.rb Test: test/functions/accounts_controller_test.rb Fixtures: test/fixtures/accounts.yml ./script/generate hobo_model_resource post title:string created_on:date body:text published:boolean Creates post model, controller & views with predefined attributes.
Version data entries
17 entries across 17 versions & 1 rubygems