| Path: | README |
| Last Update: | Tue Apr 03 09:27:06 New Zealand Standard Time 2007 |
Flex Scaffold should allow you to swap in and out different view layers on your REST controller. For example, to use the model contact, use flex_scaffold: contact
class ContactsController < ApplicationController
layout 'flex_scaffold'
flex_scaffold :contact (optional - :size => '800x600')
# The following line can be used instead of the generated definitions
# of index, show, new, edit, update, destroy. There is also the action
# schema to look at the data model
...
end
Other files that are created:
/app/flex/contacts/_list.mxml /app/flex/contacts/_contacts.mxml <-- these are compiled to a swf file /public/swfs/flex_scaffold/_contacts.swf <-- created via rake flex:app mxml=contacts /app/views/layout/flex_scaffold.rhtml <-- templated pages /app/views/flex_scaffold/index.rhtml <-- loads up the swf
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
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:
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
> db:migrate
This updates the database ready for the scaffold to pick up the columns.
> ruby script/generate flex_scaffold message
This will generate:
> rake flex:app mxml=messages
This will generate:
This Rake task infact copies the necessary assets into the build folder </tt>/app/flex</tt> 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.
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
Key features:
To do:
Long run:
I suspect that there will need to split out flex_scaffold and ActionView::Helpers::FlexObjectHelper. I would hope that flex have an equivalent set of helpers as javascript.
flex_scaffold :task do
table :only => [ :name, :role ]
form :except => [ :created_at, :updated_at ]
columns do
name do
sort("name.downcase")
is_required
end
end
end
Released under the MIT license (included)
The initial code was inspired by (or lifted from)