Sha256: cce5df1227ccea73c90ce986160665aa90c3ae7968f7f7d48ce22fb91eccb825
Contents?: true
Size: 1.71 KB
Versions: 41
Compression:
Stored size: 1.71 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 to add 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: rails generate hobo: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 Test: test/unit/account_test.rb Test: test/functions/accounts_controller_test.rb Fixtures: test/fixtures/accounts.yml (files generated may vary depending on test suite & fixture configuration) rails generate hobo:resource post title:string created_on:date body:text published:boolean Creates post model, controller & views with predefined attributes.
Version data entries
41 entries across 41 versions & 1 rubygems