Ruby on Rails | Screencasts | Download | Documentation | Weblog | Community | Source

Changeset 6884

Show
Ignore:
Timestamp:
05/29/07 02:07:08 (1 year ago)
Author:
bitsweat
Message:

Wordsmith generator USAGEs.

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • trunk/railties/lib/rails_generator/generators/components/controller/USAGE

    r6690 r6884  
    11Description: 
    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. 
    34 
    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'. 
    87 
    9     The generator creates a controller class in app/controllers with view 
    10     templates in app/views/controller_name, a helper class in app/helpers, 
    11     and a functional test 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. 
    1211 
    1312Example: 
    14     ./script/generate controller CreditCard open debit credit close 
     13    `./script/generate controller CreditCard open debit credit close` 
    1514 
    1615    Credit card controller with URLs like /credit_card/debit. 
     
    2120 
    2221Modules Example: 
    23     ./script/generate controller 'admin/credit_card' suspend late_fee 
     22    `./script/generate controller 'admin/credit_card' suspend late_fee` 
    2423 
    2524    Credit card admin controller with URLs /admin/credit_card/suspend. 
  • trunk/railties/lib/rails_generator/generators/components/integration_test/USAGE

    r4027 r6884  
    11Description: 
    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 
    95 
    106Example: 
    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  
    11Description: 
    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. 
    34 
    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. 
    98 
    109Example: 
    11     ./script/generate mailer Notifications signup forgot_password invoice 
     10    `./script/generate mailer Notifications signup forgot_password invoice` 
    1211 
    13     This will create a Notifications mailer class: 
     12    creates a Notifications mailer class, views, test, and fixtures: 
    1413        Mailer:     app/models/notifications.rb 
    1514        Views:      app/views/notifications/signup.erb [...] 
    1615        Test:       test/unit/test/unit/notifications_test.rb 
    1716        Fixtures:   test/fixtures/notifications/signup [...] 
    18  
  • trunk/railties/lib/rails_generator/generators/components/migration/USAGE

    r3945 r6884  
    11Description: 
    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. 
    95 
    106Example: 
    11     ./script/generate migration AddSslFlag 
     7    `./script/generate migration AddSslFlag` 
    128 
    13     With 4 existing migrations, this will create an AddSslFlag migration in the 
    14     file db/migrate/005_add_ssl_flag.rb 
     9    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  
    11Description: 
    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. 
    34 
    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'. 
    68 
    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. 
    1211 
    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. 
    1515 
    1616Examples: 
    17     ./script/generate model account 
     17    `./script/generate model account` 
    1818 
    19         This will create an Account model
     19        creates an Account model, test, fixture, and migration
    2020            Model:      app/models/account.rb 
    2121            Test:       test/unit/account_test.rb 
     
    2323            Migration:  db/migrate/XXX_add_accounts.rb 
    2424 
    25     ./script/generate model post title:string body:text published:boolean 
     25    `./script/generate model post title:string body:text published:boolean` 
    2626 
    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  
    11Description: 
    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. 
    34 
    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 
    86    test/unit. 
    97 
    108Example: 
    11     ./script/generate observer Account 
     9    `./script/generate observer Account` 
    1210 
    13     This will create an Account observer
     11    creates an Account observer and unit test
    1412        Observer:   app/models/account_observer.rb 
    1513        Test:       test/unit/account_observer_test.rb 
  • trunk/railties/lib/rails_generator/generators/components/plugin/USAGE

    r3215 r6884  
    11Description: 
    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. 
    35 
    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. 
    128 
    139Example: 
    14     ./script/generate plugin BrowserFilters 
     10    `./script/generate plugin BrowserFilters` 
    1511 
    16     This will create
     12    creates a standard browser_filters plugin
    1713        vendor/plugins/browser_filters/README 
    1814        vendor/plugins/browser_filters/init.rb 
     
    2420    ./script/generate plugin BrowserFilters --with-generator 
    2521 
    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: 
    3323        vendor/plugins/browser_filters/generators/browser_filters/browser_filters_generator.rb 
    3424        vendor/plugins/browser_filters/generators/browser_filters/USAGE 
  • trunk/railties/lib/rails_generator/generators/components/resource/USAGE

    r6883 r6884  
    11Description: 
    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. 
    46 
    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'. 
    910 
    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. 
    1513 
    16     By default, created_at and updated_at timestamps are added to migration 
    17     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 
    1816 
    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. 
    2919 
    3020Examples: 
    31     ./script/generate resource post # no attributes 
    32     ./script/generate resource post title:string body:text published:boolean 
    33     ./script/generate resource purchase order_id:integer amount:decimal 
     21    `./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  
    11Description: 
    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. 
    95 
    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. 
    158 
    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'. 
    2312 
    24     By default, created_at and updated_at timestamps are added to migration 
    25     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
    2615 
    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. 
    3621 
    3722Examples: 
    38     ./script/generate scaffold post # no attributes, view will be anemic 
    39     ./script/generate scaffold post title:string body:text published:boolean 
    40     ./script/generate scaffold purchase order_id:integer amount:decimal 
     23    `./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  
    11Description: 
    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. 
    105 
    116Example: 
    12     ./script/generate session_migration AddSessionTable 
     7    `./script/generate session_migration CreateSessionTable` 
    138 
    14     With 4 existing migrations, this will create an AddSessionTable migration in the 
    15     file db/migrate/005_add_session_table.rb 
     9    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  
    11Description: 
    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'. 
    46 
    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. 
    129 
    1310Example: 
    14     ./script/generate web_service User add edit list remove 
     11    `./script/generate web_service User add edit list remove` 
    1512 
    16     User web service. 
     13    creates the User controller, API, and functional test: 
    1714        Controller: app/controllers/user_controller.rb 
    1815        API:        app/apis/user_api.rb 
     
    2017 
    2118Modules Example: 
    22     ./script/generate web_service 'api/registration' register renew 
     19    `./script/generate web_service 'api/registration' register renew` 
    2320 
    24     Registration web service. 
     21    creates the Registration controller, API, and functional test: 
    2522        Controller: app/controllers/api/registration_controller.rb 
    2623        API:        app/apis/api/registration_api.rb 
    2724        Test:       test/functional/api/registration_api_test.rb 
    28