Sha256: 8946e2507984213ceabcb7a6d014302d196fabc9f3925fb16c0195ba6e5277ca

Contents?: true

Size: 1.79 KB

Versions: 227

Compression:

Stored size: 1.79 KB

Contents

Description:
    Stubs out a new model. Pass the model name, either CamelCased or
    under_scored, and an optional list of attribute pairs as arguments.

    Attribute pairs are field:type arguments specifying the
    model's attributes. Timestamps are added by default, so you don't have to
    specify them by hand as 'created_at:datetime updated_at:datetime'.

    You don't have to think up every attribute up front, but it helps to
    sketch out a few so you can start working with the model immediately.

    This generator invokes your configured ORM and test framework, which
    defaults to ActiveRecord and TestUnit.

    Finally, if --parent option is given, it's used as superclass of the
    created model. This allows you create Single Table Inheritance models.

    If you pass a namespaced model name (e.g. admin/account or Admin::Account)
    then the generator will create a module with a table_name_prefix method
    to prefix the model's table name with the module name (e.g. admin_account)

Examples:
    `rails generate model account`

        For ActiveRecord and TestUnit it creates:

            Model:      app/models/account.rb
            Test:       test/unit/account_test.rb
            Fixtures:   test/fixtures/accounts.yml
            Migration:  db/migrate/XXX_add_accounts.rb

    `rails generate model post title:string body:text published:boolean`

        Creates a Post model with a string title, text body, and published flag.

    `rails generate model admin/account`

        For ActiveRecord and TestUnit it creates:

            Module:     app/models/admin.rb
            Model:      app/models/admin/account.rb
            Test:       test/unit/admin/account_test.rb
            Fixtures:   test/fixtures/admin/accounts.yml
            Migration:  db/migrate/XXX_add_admin_accounts.rb

Version data entries

227 entries across 188 versions & 19 rubygems

Version Path
railties-3.2.14.rc1 lib/rails/generators/rails/model/USAGE
swipe-rails-0.0.5 vendor/bundle/gems/railties-3.2.13/lib/rails/generators/rails/model/USAGE
active_mailer-0.0.9 test/fixtures/dummyapp_rails_3.2/vendor/bundle/ruby/1.9.1/gems/railties-3.2.12/lib/rails/generators/rails/model/USAGE
active_mailer-0.0.8 test/fixtures/dummyapp_rails_3.2/vendor/bundle/ruby/1.9.1/gems/railties-3.2.12/lib/rails/generators/rails/model/USAGE
active_mailer-0.0.7 test/fixtures/dummyapp_rails_3.2/vendor/bundle/ruby/1.9.1/gems/railties-3.2.12/lib/rails/generators/rails/model/USAGE
active_mailer-0.0.6 test/fixtures/dummyapp_rails_3.2/vendor/bundle/ruby/1.9.1/gems/railties-3.2.12/lib/rails/generators/rails/model/USAGE
font-awesome-rails-3.1.1.2 vendor/ruby/1.9.1/gems/railties-3.2.13/lib/rails/generators/rails/model/USAGE
font-awesome-rails-3.1.1.2 vendor/ruby/1.9.1/gems/railties-3.2.12/lib/rails/generators/rails/model/USAGE
font-awesome-rails-3.1.1.2 vendor/ruby/2.0.0/gems/railties-3.2.12/lib/rails/generators/rails/model/USAGE
font-awesome-rails-3.1.1.1 vendor/ruby/2.0.0/gems/railties-3.2.12/lib/rails/generators/rails/model/USAGE
font-awesome-rails-3.1.1.1 vendor/ruby/1.9.1/gems/railties-3.2.13/lib/rails/generators/rails/model/USAGE
font-awesome-rails-3.1.1.1 vendor/ruby/1.9.1/gems/railties-3.2.12/lib/rails/generators/rails/model/USAGE
challah-1.0.0.beta3 vendor/bundle/gems/railties-3.2.13/lib/rails/generators/rails/model/USAGE
fc-webicons-0.0.4 vendor/bundle/ruby/1.9.1/gems/railties-3.2.13/lib/rails/generators/rails/model/USAGE
challah-1.0.0.beta2 vendor/bundle/gems/railties-3.2.13/lib/rails/generators/rails/model/USAGE
challah-1.0.0.beta vendor/bundle/gems/railties-3.2.13/lib/rails/generators/rails/model/USAGE
challah-1.0.0.beta vendor/bundle/gems/railties-3.2.11/lib/rails/generators/rails/model/USAGE
fc-webicons-0.0.3 vendor/bundle/ruby/1.9.1/gems/railties-3.2.13/lib/rails/generators/rails/model/USAGE
fc-webicons-0.0.2 vendor/bundle/ruby/1.9.1/gems/railties-3.2.13/lib/rails/generators/rails/model/USAGE
fc-webicons-0.0.1 vendor/bundle/ruby/1.9.1/gems/railties-3.2.13/lib/rails/generators/rails/model/USAGE