Flex Scaffold - Usage

Summary

To generate a scaffold for the model message with fields title and body:

  > ruby script/generate flex_scaffold_resource message title:string body:string
  > rake db:migrate
  > ruby script/generate flex_scaffold message
  > rake flex:app mxml=messages
  > ruby script/server start


1. Install a REST service from flex_scaffold_resource

Create an Active Resource (REST service)

  > ruby script/generate flex_scaffold_resource message title:string body:string


This simple command will generate a lot of stuff, in detail:

* A controller with REST actions and an action for getting the schema
* A model named message
* A migration named xxx_create_messages
* Fixture and unit tests for the model and the controller
* A line in your config/routes.rb file map.resources :messages

Alternatively, you can add scaffolding to any REST resources by adding to any controller:

  flex_scaffold :message


Note: You can then delete or extend all the other REST actions as they are implicitly scaffolded
2. Migrate the database

  > db:migrate


This updates the database ready for the scaffold to pick up the columns.
3. Create the scaffolds

  > ruby script/generate flex_scaffold message


This will generate:

* A scaffold view for the controller which loads the swf
* A template layout for the controller
* Scaffolded mxml files (in app/flex)

4. Compile the scaffolds

  > rake flex:app mxml=messages


This will generate:

* copy assets into the /app/flex/ folder ready for compilation (see below)
* compile the swf files based on the configuration in the related controller to /app/flex/
* save the resulting swf in /public/swfs/flex_scaffold
* ensure that all needed public assets are copied to /public/ [stylesheets, javascript] (also see Restart server below)

This Rake task infact copies the necessary assets into the build folder /app/flex and then remove when finished. To avoid you compile only. This would involved steps either side for use:

 > rake flex:build:install mxml=contacts  [move the assets into the build structure]
 > rake flex:compile mxml=contacts        [repeat this as many times as needed]


Optionally you may wish to clean up:

 > rake flex:build:clobber mxml=contacts


Note: There is currently no way to build multiple scaffolds at one time.

5. (Re)Start server?

Just check this. You should only need to restart the start to init the plugin. This will also copy the correct files to public which is equivalent to the Rake task: rake flex:public:install

Edit documentation | (0 older versions) | Last edited by: hardway, 9 months ago