Changeset 6884
- Timestamp:
- 05/29/07 02:07:08 (1 year ago)
- Files:
-
- trunk/railties/lib/rails_generator/generators/components/controller/USAGE (modified) (2 diffs)
- trunk/railties/lib/rails_generator/generators/components/integration_test/USAGE (modified) (1 diff)
- trunk/railties/lib/rails_generator/generators/components/mailer/USAGE (modified) (1 diff)
- trunk/railties/lib/rails_generator/generators/components/migration/USAGE (modified) (1 diff)
- trunk/railties/lib/rails_generator/generators/components/model/USAGE (modified) (2 diffs)
- trunk/railties/lib/rails_generator/generators/components/observer/USAGE (modified) (1 diff)
- trunk/railties/lib/rails_generator/generators/components/plugin/USAGE (modified) (2 diffs)
- trunk/railties/lib/rails_generator/generators/components/resource/USAGE (modified) (1 diff)
- trunk/railties/lib/rails_generator/generators/components/scaffold/USAGE (modified) (1 diff)
- trunk/railties/lib/rails_generator/generators/components/session_migration/USAGE (modified) (1 diff)
- trunk/railties/lib/rails_generator/generators/components/web_service/USAGE (modified) (2 diffs)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
trunk/railties/lib/rails_generator/generators/components/controller/USAGE
r6690 r6884 1 1 Description: 2 The controller generator creates stubs for a new controller and its views. 2 Stubs out a new controller and its views. Pass the controller name, either 3 CamelCased or under_scored, and a list of views as arguments. 3 4 4 The generator takes a controller name and a list of views as arguments. 5 The controller name may be given in CamelCase or under_score and should 6 not be suffixed with 'Controller'. To create a controller within a 7 module, specify the controller name as 'module/controller'. 5 To create a controller within a module, specify the controller name as a 6 path like 'parent_module/controller_name'. 8 7 9 Th e generator creates a controller class in app/controllers with view10 templates in app/views/controller_name, a helper class in app/helpers,11 and a functionaltest suite in test/functional.8 This generates a controller class in app/controllers, view templates in 9 app/views/controller_name, a helper class in app/helpers, and a functional 10 test suite in test/functional. 12 11 13 12 Example: 14 ./script/generate controller CreditCard open debit credit close13 `./script/generate controller CreditCard open debit credit close` 15 14 16 15 Credit card controller with URLs like /credit_card/debit. … … 21 20 22 21 Modules Example: 23 ./script/generate controller 'admin/credit_card' suspend late_fee22 `./script/generate controller 'admin/credit_card' suspend late_fee` 24 23 25 24 Credit card admin controller with URLs /admin/credit_card/suspend. trunk/railties/lib/rails_generator/generators/components/integration_test/USAGE
r4027 r6884 1 1 Description: 2 The model generator creates a stub for a new integration test. 3 4 The generator takes an integration test name as its argument. The test 5 name may be given in CamelCase or under_score and should not be suffixed 6 with 'Test'. 7 8 The generator creates an integration test class in test/integration. 2 Stubs out a new integration test. Pass the name of the test, either 3 CamelCased or under_scored, as an argument. The new test class is 4 generated in test/integration/testname_test.rb 9 5 10 6 Example: 11 ./script/generate integration_test GeneralStories 12 13 This will create a GeneralStores integration test: 14 test/integration/general_stories_test.rb 7 `./script/generate integration_test GeneralStories` creates a GeneralStories 8 integration test in test/integration/general_stories_test.rb trunk/railties/lib/rails_generator/generators/components/mailer/USAGE
r6180 r6884 1 1 Description: 2 The mailer generator creates stubs for a new mailer and its views. 2 Stubs out a new mailer and its views. Pass the mailer name, either 3 CamelCased or under_scored, and an optional list of emails as arguments. 3 4 4 The generator takes a mailer name and a list of views as arguments. 5 The mailer name may be given in CamelCase or under_score. 6 7 The generator creates a mailer class in app/models with view templates 8 in app/views/mailer_name, and a test suite with fixtures in test/unit. 5 This generates a mailer class in app/models, view templates in 6 app/views/mailer_name, a unit test in test/unit, and fixtures in 7 test/fixtures. 9 8 10 9 Example: 11 ./script/generate mailer Notifications signup forgot_password invoice10 `./script/generate mailer Notifications signup forgot_password invoice` 12 11 13 This will create a Notifications mailer class:12 creates a Notifications mailer class, views, test, and fixtures: 14 13 Mailer: app/models/notifications.rb 15 14 Views: app/views/notifications/signup.erb [...] 16 15 Test: test/unit/test/unit/notifications_test.rb 17 16 Fixtures: test/fixtures/notifications/signup [...] 18 trunk/railties/lib/rails_generator/generators/components/migration/USAGE
r3945 r6884 1 1 Description: 2 The migration generator creates a stub for a new database migration. 3 4 The generator takes a migration name as its argument. The migration name may be 5 given in CamelCase or under_score. 6 7 The generator creates a migration class in db/migrate prefixed by its number 8 in the queue. 2 Stubs out a new database migration. Pass the migration name, either 3 CamelCased or under_scored, as an argument. A migration class is generated 4 in db/migrate prefixed by the latest migration number. 9 5 10 6 Example: 11 ./script/generate migration AddSslFlag7 `./script/generate migration AddSslFlag` 12 8 13 With 4 existing migrations, this will create an AddSslFlag migration in the14 filedb/migrate/005_add_ssl_flag.rb9 With 4 existing migrations, this creates the AddSslFlag migration in 10 db/migrate/005_add_ssl_flag.rb trunk/railties/lib/rails_generator/generators/components/model/USAGE
r6883 r6884 1 1 Description: 2 The model generator creates stubs for a new model. 2 Stubs out a new model. Pass the model name, either CamelCased or 3 under_scored, and an optional list of attribute pairs as arguments. 3 4 4 The generator takes a model name as its argument. The model name may be given in CamelCase or under_score and 5 should not be suffixed with 'Model'. 5 Attribute pairs are column_name:sql_type arguments specifying the 6 model's attributes. Timestamps are added by default, so you don't have to 7 specify them by hand as 'created_at:datetime updated_at:datetime'. 6 8 7 As additional parameters, the generator will take attribute pairs described by name and type. These attributes will 8 be used to prepopulate the migration to create the table for the model and give you a set of predefined fixture. By 9 default, created_at and updated_at timestamps are added to migration for you, so you needn't specify them by hand. 10 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 11 needed to start really working with the resource. 9 You don't have to think up every attribute up front, but it helps to 10 sketch out a few so you can start working with the model immediately. 12 11 13 The generator creates a model class in app/models, a test suite in test/unit, test fixtures in 14 test/fixtures/singular_name.yml, and a migration in db/migrate. 12 This generates a model class in app/models, a unit test in test/unit, 13 a test fixture in test/fixtures/singular_name.yml, and a migration in 14 db/migrate. 15 15 16 16 Examples: 17 ./script/generate model account17 `./script/generate model account` 18 18 19 This will create an Account model:19 creates an Account model, test, fixture, and migration: 20 20 Model: app/models/account.rb 21 21 Test: test/unit/account_test.rb … … 23 23 Migration: db/migrate/XXX_add_accounts.rb 24 24 25 ./script/generate model post title:string body:text published:boolean25 `./script/generate model post title:string body:text published:boolean` 26 26 27 Creates post model with predefined attributes.27 creates a Post model with a string title, text body, and published flag. trunk/railties/lib/rails_generator/generators/components/observer/USAGE
r4365 r6884 1 1 Description: 2 The observer generator creates stubs for a new observer. 2 Stubs out a new observer. Pass the observer name, either CamelCased or 3 under_scored, as an argument. 3 4 4 The generator takes a observer name as its argument. The observer name may be 5 given in CamelCase or under_score and should not be suffixed with 'Observer'. 6 7 The generator creates a observer class in app/models and a test suite in 5 The generator creates an observer class in app/models and a unit test in 8 6 test/unit. 9 7 10 8 Example: 11 ./script/generate observer Account9 `./script/generate observer Account` 12 10 13 This will create an Account observer:11 creates an Account observer and unit test: 14 12 Observer: app/models/account_observer.rb 15 13 Test: test/unit/account_observer_test.rb trunk/railties/lib/rails_generator/generators/components/plugin/USAGE
r3215 r6884 1 1 Description: 2 The plugin generator creates stubs for a new plugin. 2 Stubs out a new plugin. Pass the plugin name, either CamelCased or 3 under_scored, as an argument. Pass --with-generator to add an example 4 generator also. 3 5 4 The generator takes a plugin name as its argument. The plugin name may be 5 given in CamelCase or under_score and should not be suffixed with 'Plugin'. 6 7 The generator creates a plugin directory in vendor/plugins that includes 8 both init.rb and README files as well as lib, task, and test directories. 9 10 It's also possible to generate stub files for a generator to go with the 11 plugin by using --with-generator 6 This creates a plugin in vendor/plugins including an init.rb and README 7 as well as standard lib, task, and test directories. 12 8 13 9 Example: 14 ./script/generate plugin BrowserFilters10 `./script/generate plugin BrowserFilters` 15 11 16 This will create:12 creates a standard browser_filters plugin: 17 13 vendor/plugins/browser_filters/README 18 14 vendor/plugins/browser_filters/init.rb … … 24 20 ./script/generate plugin BrowserFilters --with-generator 25 21 26 This will create: 27 vendor/plugins/browser_filters/README 28 vendor/plugins/browser_filters/init.rb 29 vendor/plugins/browser_filters/install.rb 30 vendor/plugins/browser_filters/lib/browser_filters.rb 31 vendor/plugins/browser_filters/test/browser_filters_test.rb 32 vendor/plugins/browser_filters/tasks/browser_filters_tasks.rake 22 creates a browser_filters generator also: 33 23 vendor/plugins/browser_filters/generators/browser_filters/browser_filters_generator.rb 34 24 vendor/plugins/browser_filters/generators/browser_filters/USAGE trunk/railties/lib/rails_generator/generators/components/resource/USAGE
r6883 r6884 1 1 Description: 2 The resource generator creates an empty model, controller, and functional 3 test suitable for a RESTful, resource-oriented application. 2 Stubs out a new resource including an empty model and controller suitable 3 for a restful, resource-oriented application. Pass the singular model name, 4 either CamelCased or under_scored, as the first argument, and an optional 5 list of attribute pairs. 4 6 5 The generator takes the name of the model as its first argument. This 6 model name is then pluralized to get the controller name. So "resource 7 post" will generate a Post model and a PostsController and will be 8 intended for URLs like /posts and /posts/45. 7 Attribute pairs are column_name:sql_type arguments specifying the 8 model's attributes. Timestamps are added by default, so you don't have to 9 specify them by hand as 'created_at:datetime updated_at:datetime'. 9 10 10 As additional parameters, the generator will take attribute pairs 11 described by name and type. These attributes will be used to 12 prepopulate the migration to create the table for the model. For 13 example, "resource post title:string body:text published:boolean" will 14 give you a Post model with those three attributes. 11 You don't have to think up every attribute up front, but it helps to 12 sketch out a few so you can start working with the resource immediately. 15 13 16 By default, created_at and updated_at timestamps are added to migration17 for you, so you needn't specify them by hand.14 This creates a model, controller, tests and fixtures for both, and the 15 corresponding map.resources declaration in config/routes.rb 18 16 19 You don't have to think up all attributes up front, but it's a good 20 idea of adding just the baseline of what's needed to start really 21 working with the resource. 22 23 The generator also adds an appropriate map.resources declaration to 24 your config/routes.rb file, hooking up the rules that'll point URLs to 25 this new resource. 26 27 Unlike the scaffold generator, the resource generator does not 28 create views or add any methods to the generated controller. 17 Unlike the scaffold generator, the resource generator does not create 18 views or add any methods to the generated controller. 29 19 30 20 Examples: 31 ./script/generate resource post# no attributes32 ./script/generate resource post title:string body:text published:boolean33 ./script/generate resource purchase order_id:integer amount:decimal21 `./script/generate resource post` # no attributes 22 `./script/generate resource post title:string body:text published:boolean` 23 `./script/generate resource purchase order_id:integer amount:decimal` trunk/railties/lib/rails_generator/generators/components/scaffold/USAGE
r6883 r6884 1 1 Description: 2 The scaffold resource generator creates a model, a controller, and a 3 set of templates that's ready to use as the starting point for your 4 REST-like, resource-oriented application. This basically means that it 5 follows a set of conventions to exploit the full set of HTTP verbs 6 (GET/POST/PUT/DELETE) and is prepared for multi-client access (like one 7 view for HTML, one for an XML API, one for ATOM, etc). Everything comes 8 with sample unit and functional tests as well. 2 Scaffolds an entire resource, from model and migration to controller and 3 views, along with a full test suite. The resource is ready to use as a 4 starting point for your restful, resource-oriented application. 9 5 10 The generator takes the name of the model as its first argument. This 11 model name is then pluralized to get the controller name. So 12 "scaffold post" will generate a Post model and a 13 PostsController and will be intended for URLs like /posts and 14 /posts/45. 6 Pass the name of the model, either CamelCased or under_scored, as the first 7 argument, and an optional list of attribute pairs. 15 8 16 As additional parameters, the generator will take attribute pairs 17 described by name and type. These attributes will be used to 18 prepopulate the migration to create the table for the model and to give 19 you a set of templates for the view. For example, "scaffold post 20 title:string body:text published:boolean" will give you a model with 21 those three attributes, forms to create and edit those models from, 22 and an index that'll list them all. 9 Attribute pairs are column_name:sql_type arguments specifying the 10 model's attributes. Timestamps are added by default, so you don't have to 11 specify them by hand as 'created_at:datetime updated_at:datetime'. 23 12 24 By default, created_at and updated_at timestamps are added to migration25 for you, so you needn't specify them by hand.13 You don't have to think up every attribute up front, but it helps to 14 sketch out a few so you can start working with the resource immediately. 26 15 27 You don't have to think up all attributes up front, but it's a good 28 idea of adding just the baseline of what's needed to start really 29 working with the resource. 30 31 The generator also adds a declaration to your config/routes.rb file 32 to hook up the rules that'll point URLs to this new resource. If you 33 create a resource like "scaffold post", it will add 34 "map.resources :posts" (notice the plural form) in the routes file, 35 making your new resource accessible from /posts. 16 For example, `scaffold post title:string body:text published:boolean` 17 gives you a model with those three attributes, a controller that handles 18 the create/show/update/destroy, forms to create and edit your posts, and 19 an index that lists them all, as well as a map.resources :posts 20 declaration in config/routes.rb. 36 21 37 22 Examples: 38 ./script/generate scaffold post# no attributes, view will be anemic39 ./script/generate scaffold post title:string body:text published:boolean40 ./script/generate scaffold purchase order_id:integer amount:decimal23 `./script/generate scaffold post` # no attributes, view will be anemic 24 `./script/generate scaffold post title:string body:text published:boolean` 25 `./script/generate scaffold purchase order_id:integer amount:decimal` trunk/railties/lib/rails_generator/generators/components/session_migration/USAGE
r3945 r6884 1 1 Description: 2 The session table migration generator creates a migration for adding a session table 3 used by CGI::Session::ActiveRecordStore. 4 5 The generator takes a migration name as its argument. The migration name may be 6 given in CamelCase or under_score. 7 8 The generator creates a migration class in db/migrate prefixed by its number 9 in the queue. 2 Creates a migration to add the sessions table used by the Active Record 3 session store. Pass the migration name, either CamelCased or under_scored, 4 as an argument. 10 5 11 6 Example: 12 ./script/generate session_migration AddSessionTable7 `./script/generate session_migration CreateSessionTable` 13 8 14 With 4 existing migrations, this will create an AddSessionTable migration in the15 filedb/migrate/005_add_session_table.rb9 With 4 existing migrations, this creates the AddSessionTable migration 10 in db/migrate/005_add_session_table.rb trunk/railties/lib/rails_generator/generators/components/web_service/USAGE
r851 r6884 1 1 Description: 2 The web service generator creates the controller and API definition for 3 a web service. 2 Stubs out the controller and API for a new web service using the deprecated 3 Action Web Service framework. Pass the web service name, either CamelCased 4 or under_scored, and a list of API methods as arguments. To create a web 5 service within a module, use a path like 'module_name/web_service_name'. 4 6 5 The generator takes a web service name and a list of API methods as arguments. 6 The web service name may be given in CamelCase or under_score and should 7 contain no extra suffixes. To create a web service within a 8 module, specify the web service name as 'module/webservice'. 9 10 The generator creates a controller class in app/controllers, an API definition 11 in app/apis, and a functional test suite in test/functional. 7 This generates a controller in app/controllers, an API definition 8 in app/apis, and functional tests in test/functional. 12 9 13 10 Example: 14 ./script/generate web_service User add edit list remove11 `./script/generate web_service User add edit list remove` 15 12 16 User web service.13 creates the User controller, API, and functional test: 17 14 Controller: app/controllers/user_controller.rb 18 15 API: app/apis/user_api.rb … … 20 17 21 18 Modules Example: 22 ./script/generate web_service 'api/registration' register renew19 `./script/generate web_service 'api/registration' register renew` 23 20 24 Registration web service.21 creates the Registration controller, API, and functional test: 25 22 Controller: app/controllers/api/registration_controller.rb 26 23 API: app/apis/api/registration_api.rb 27 24 Test: test/functional/api/registration_api_test.rb 28