Using the Ruby On Rails plugin from FlashBuilder4

Make sure you followed the post Installing Ruby On Rails plugin for FlashBuilder4 for installing the plugin and setting up of your Rails project before proceeding with the usage of the plugin from FlashBuilder.

Using the plugin from FlashBuilder4:

1. Create a new Flex Project.

-In the New Project Wizard, name the project, lets say "TestROR", select the application type and make sure that you enter Application Server type as None/Other, click next.

-Enter the output folder to be something under the publicly accessible directory under your rails project, ex: C:\RubyProjects\myrailsproject\public\TestROR, click next

-Enter the Output folder url as the url which points to the output folder created above ex: http://localhost:3000/TestROR

Exit the wizard by clicking finish.

2. Creating a new Service

- In the Data/Services Panel click Connect to Data/Service..., when the Connect to Data/Service wizard opens select "ROR" icon and click next.

- On the next page, select the services folder. The services folder is the directory under which any ruby class will be exposed as a service. For "WebOrb" as the AMF library this will reside under the app folder under the project folder. ex: C:\RubyProjects\myrailsproject\app\services

Provide the AMF endpoint. By default the plugin assumes that the AMF library is WebOrb and the user will be using the default destination. You can change it to provide the endpoint of the destination of your choice.

You can then select between creation of a new service or import of an existing service.

Selecting "Generate a new Ruby service class from a model" means that the plugin will generate a class exposing all the CRUD(create,read,update,delete) functions as a service for the mentioned model. This class will be placed under the already mentioned services folder.

You will then provide the name of the model. The name of the model is the same that is used in the common ruby command ruby script/generate model modelname . The model name here corresponds to the underlying database table. Rails naming convention makes the table name to end with a "s" while the model name does not have the "s" ex: If the table name is "Users" the model name will be "User".

You can then select if the model already exists or not. If you select that the model exists then the model class won't be generated, otherwise the user will then need to provide the directory where the model class will reside on generation. Generally it is under the app folder under the project folder ex: C:\RubyProjects\myrailsproject\app\models

Selecting "Import an existing Ruby service class" will simply import the mentioned class without any server side code generation. The ruby file location should be under the mentioned services folder for it to be exposed as a service.

Click finish.

3. Using the created service

The created service will appear in the Data/Services panel. All the operations in the service class and the model class will be imported.

If you selected ""Generate a new Ruby service class from a model" in the previous step you will find that the service is automatically created with DataManagement on the model as turned on, with the paging function also assigned.

If you selected otherwise only the operations will get listed and no data types will appear. All the operations will also be weakly typed (unknown input types and return types). You will have to manually configure the return types using Configure Return type... on right clicking on the operations.

Using this service is same as using any other service under the DCD workflow in FlashBuilder4.

Find more about DCD service usage and data management at http://sujitreddyg.wordpress.com/flash-builder-4

Installing Ruby On Rails plugin for FlashBuilder4

Untitled Document

The Ruby On Rails plugin allows FlashBuilder4's DCD workflow to support AMF(Remoting) based services running on Ruby on Rails driven servers.

Installation of the plugin:

1.Download the plugin and unzip it.

2.Close FlashBuilder4 if it is running.

3.Go to the plugins directory.
- For standalone version of FlashBuiler4 it is located at:
/plugins
- For plugin version of FlashBuilder4 it is located at:
/eclipse/plugins

4.Copy the plugin folder "com.adobe.flexbuilder.services.RORService_1.0.0" in the unzipped folder mentioned in "1." to the plugins directory mentioned in "2."

5. Restart FlashBuilder4.

ROR Service icon should now appear in the Connect to Data/Service wizard.

Setting up of the Rails project for use with this plugin:

Following steps assume that you already have ruby and rails installed on your system.

1. Get to your rails project on the command prompt. If have not created a rails project use something like "rails myrailsproject" to create one.

2. In order to make your ruby classes available as remoting(AMF) services we need to install an AMF library for this purpose. One such library is "WebOrb for rails" provided by The Midnight Coders.(http://www.themidnightcoders.com/products/weborb-for-rails/overview.html). We will be using this library for the examples, but the users are free to choose their own library of choice. However using WebOrb will make the understanding of the examples easier.
Install weborb in your project folder using the command:
ruby script/plugin install http://themidnightcoders.net:8089/svn/weborb

3. Run the server using: ruby script/server

If you get an error similar to:
c:/ruby/lib/ruby/gems/1.8/gems/actives
upport-2.2.2/lib/active_support/dependencies.rb:105:in `const_missing': uninitia
lized constant Rails::Plugin::Dependencies (NameError)
from F:/trails/m2/vendor/plugins/weborb/init.rb:30:in `evaluate_init_rb'

Then modify the file init.rb in /vendor/plugins/weborb/init.rb as:

Replace
Dependencies.mechanism = :load

with:
ActiveSupport::Dependencies.mechanism = :load

Reason of error: In the new Rails framework, Dependencies are part of ActiveSupport now

4.Make sure database.yml is edited and points to a running Database.

BlogCFC was created by Raymond Camden. This blog is running version 5.5.006. | Protected by Akismet | Blog with WordPress