Sha256: 8ca995c7e84ecd6a6aaaf1eb9a5fd554dc7aba36548106a2204e74a8e62df65f
Contents?: true
Size: 1.62 KB
Versions: 33
Compression:
Stored size: 1.62 KB
Contents
Description: Stubs out a new content block. Pass the content block name, either CamelCased or under_scored, and an optional list of attribute pairs as arguments. Attribute pairs are column_name:sql_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'. The name:string attribute is also implicitly generated as part of the migration and to the forms, but you can override it by specifying a different type, like name:text. This generates a model, controller, several partial views, a migration and tests in the appropriate directories. Examples: `./script/generate content_block article` creates an Article model, controller, views, tests, and migration: Model: app/models/article.rb Unit Test: test/unit/models/article_test.rb Migration: db/migrate/XXX_create_article.rb Controller: app/controllers/cms/article_controller.rb Functional Test: test/functional/cms/article_controler_test.rb Form Partials: app/views/cms/articles/_form.html.erb app/views/cms/articles/render.html.erb This block will have a single attribute, name:string and a form with text_field to edit the name. `./script/generate content_block Article name:string body:text published:boolean` creates an Article model with a string name, text body, and published flag. It will create form fields for these attributes in _form.html.erb.
Version data entries
33 entries across 33 versions & 10 rubygems