Welcome!

Adobe Flex Authors: Matthew Lobas, PR.com Newswire, Shelly Palmer, Kevin Benedict

Related Topics: Adobe Flex, Open Source Cloud

Adobe Flex: Article

Adobe Flex: Flexstore on Rails Tutorial

Flexstore is a traditional Shopping Cart application. In this tutorial, we create two modules

Flexstore is a traditional Shopping Cart application. In this tutorial, we create two modules:

  1. The administration module is an internal application used to maintain the product database. You use the administration module to create, update, and delete products.
  2. The store module is a customer-facing application. Customers use the store module to browse and filter the product catalog.
In the administration module, we use Rails' simple scaffolding feature to automatically provide the default infrastructure to list, view, create, edit, and delete products. In the store module, we experiment with additional features:
  • Templates
  • Filtering using AJAX
  • Partial Page Templates
  • Builder Templates
  • Putting a Flex front-end on top of a Ruby on Rails application
This tutorial uses a MySQL database. It is assumed that you already have MySQL up and running.

Create the Flexstore Database
1.  Create a database called "flexstore"
Open a command prompt, navigate to the bin directory of your MySQL Server installation, and type the following command:

mysqladmin -uroot create flexstore

2.  Import the data

Install Ruby and Rails
1.  Install Ruby2.  Install Rails
Type the following command in the c:\ruby directory:

gem install rails --remote --include-dependencies

Create the Administration Module
1.  Create the Flexstore application

  • Create a directory called Rails in c:\
  • Type the following command in c:\rails:

rails flexstore

2.  Configure the database for the flexstore application

  • Edit database.yml in c:\rails\flexstore\config
  • Set the database parameter to flexstore in the development, test, and production sections
3.  Create a controller for the administration module
Type the following command in c:\rails\flexstore

ruby script\generate controller
Admin

4.  Create a model for the products
Type the following command in c:\rails\flexstore:

ruby script\generate model Product

5.  Modify the admin controller to enable Rails' scaffolding

  • Edit admin_controller.rb in c:\rails\flexstore\app\controllers
  • Modify the class as shown in Figure 1.
6.  Test the application
  • Start the WEBrick web server installed with Rails
    Type the following command in c:\rails\flexstore:

    ruby script\server

  • Open a browser and access the following URL:

    http://localhost:3000/admin

Rails' scaffolding defined in the Admin controller automatically provides default actions and views to list, view, create, edit and delete products. Each of these actions and views can be overwritten. We overwrite the default index action in the next steps.

7.  Define a custom index action

  • Edit admin_controller.rb in c:\rails\flexstore\app\controllers
  • Define an index action as shown in Figure 2.
8.  Create the view for the index action
  • Create a file name index.rhtml in c:\rails\flexstore\app\views\admin
  • Edit index.rhtml as follows:

<html>
<head>
<title>Product List</title>
</head>
<body>
<table>
<tr>
<td>Name</td>
<td>Price</td>
</tr>
<% @products.each do |product| %>
<tr>
<td><%= link_to product.name, :action => "show", :id => product.id %></td>
<td align="right"><%= sprintf("$%0.2f", product.price) %></td>
</tr>
<% end %>
</table>
<p><%= link_to "Create new product", :action => "new" %></p>
</body>
</html>

9.  Test the application. Open a browser and access the following URL:

http://localhost:3000/admin

10.  Validation

  • Edit product.rb in c:\rails\flexstore\app\models
  • Modify the class as shown in Figure 3.
11.  Test the application again. Try to add a product without a name or with a non numeric price value.

Create the Store Module
1. Deploy the product images and the flexstore stylesheet

2.  Create a controller for the administration module
Type the following command in c:\rails\flexstore:

ruby script\generate controller Store

3.  Define an index action in the Store controller

  • Edit store_controller.rb in c:\rails\flexstore\app\controllers
  • Define an index action as shown in Figure 4.
4.  Create the view for the index action
  • Create a file name index.rhtml in c:\rails\flexstore\app\views\store
  • Edit index.rhtml as follows:

<html>
<head>
<title>Flexstore on Rails</title>
<%= stylesheet_link_tag "flexstore", :media => "all" %>
</head>
<body>
<!-- begin catalog -->
<div id="catalog">
<% for product in @products %>
<!-- begin thumbnail -->
<div class="thumbnail">
<strong><%= product.name %></strong>
<img src="<%= product.image %>"/>
<div>
<font color="#CC6600"><b><%= sprintf("$%0.2f", product.price) %></b></font>
<p>
<%= product.camera==1?'Camera<br />':'' %>
<%= product.video==1?'Video<br />':'' %>
<%= product.triband==1?'Triband':'' %>
</p>
</div>
</div>
<!-- end thumbnail -->
<% end %>
</div>
<!-- end catalog -->
</body>
</html>

5.  Test the application
Open a browser and access the following URL:

http://localhost:3000/store


More Stories By Christophe Coenraets

Christophe Coenraets currently works as a Senior Technical Evangelist at Adobe. Before joining Adobe, Christophe was an evangelist at Macromedia, focusing on Rich Internet Applications and Enterprise integration. Prior to Macromedia, Christophe was the head of Java and J2EE Technical Evangelism at Sybase, where he started working on Java Enterprise projects in 1996. Before joining Sybase in the US, Christophe held different positions at Powersoft in Belgium, including Principal Consultant for PowerBuilder, and Manager of the Professional Services organization. Before joining Powersoft, Christophe worked as a developer and architect on several retail and BPM projects. Christophe has been a regular speaker at conferences worldwide for the last 10 years.

Comments (12) View Comments

Share your thoughts on this story.

Add your comment
You must be signed in to add a comment. Sign-in | Register

In accordance with our Comment Policy, we encourage comments that are on topic, relevant and to-the-point. We will remove comments that include profanity, personal attacks, racial slurs, threats of violence, or other inappropriate material that violates our Terms and Conditions, and will block users who make repeated violations. We ask all readers to expect diversity of opinion and to treat one another with dignity and respect.


Most Recent Comments
newgen315 09/09/08 01:42:18 PM EDT

Hi,
Where would be the sql files mentioned in the article. I look all over for them and would appreciate a link

SYS-CON Australia News Desk 07/20/06 02:45:34 PM EDT

Flexstore is a traditional Shopping Cart application. In this tutorial, we create two modules: The administration module is an internal application used to maintain the product database. You use the administration module to create, update, and delete products. The store module is a customer-facing application. Customers use the store module to browse and filter the product catalog.

Web Developer's & Designer's Journal 07/20/06 02:00:15 PM EDT

Flexstore is a traditional Shopping Cart application. In this tutorial, we create two modules: The administration module is an internal application used to maintain the product database. You use the administration module to create, update, and delete products. The store module is a customer-facing application. Customers use the store module to browse and filter the product catalog.

SYS-CON Australia News Desk 07/11/06 05:06:58 PM EDT

Flexstore is a traditional Shopping Cart application. In this tutorial, we create two modules: The administration module is an internal application used to maintain the product database. You use the administration module to create, update, and delete products. The store module is a customer-facing application. Customers use the store module to browse and filter the product catalog.

SYS-CON Brazil News Desk 07/11/06 04:53:01 PM EDT

Flexstore is a traditional Shopping Cart application. In this tutorial, we create two modules: The administration module is an internal application used to maintain the product database. You use the administration module to create, update, and delete products. The store module is a customer-facing application. Customers use the store module to browse and filter the product catalog.

Paul Blackburn 07/11/06 04:08:45 PM EDT

I enjoyed your tutorial, but have a little problem with it. Everything worked until the Flex part. I get an error msessage like this: "Error: 'FABridge.store' is null or not an object"

Thanks

Web Developer's & Designer's Journal 05/22/06 04:19:09 PM EDT

Flexstore is a traditional Shopping Cart application. In this tutorial, we create two modules: The administration module is an internal application used to maintain the product database. You use the administration module to create, update, and delete products. The store module is a customer-facing application. Customers use the store module to browse and filter the product catalog.

SYS-CON Italy News Desk 05/19/06 10:54:06 AM EDT

Flexstore is a traditional Shopping Cart application. In this tutorial, we create two modules: The administration module is an internal application used to maintain the product database. You use the administration module to create, update, and delete products. The store module is a customer-facing application. Customers use the store module to browse and filter the product catalog.

SYS-CON Australia News Desk 05/19/06 07:46:21 AM EDT

Flexstore is a traditional Shopping Cart application. In this tutorial, we create two modules: The administration module is an internal application used to maintain the product database. You use the administration module to create, update, and delete products. The store module is a customer-facing application. Customers use the store module to browse and filter the product catalog.

AJAX News Desk 05/18/06 06:42:12 PM EDT

Flexstore is a traditional Shopping Cart application. In this tutorial, we create two modules: The administration module is an internal application used to maintain the product database. You use the administration module to create, update, and delete products. The store module is a customer-facing application. Customers use the store module to browse and filter the product catalog.

SYS-CON India News Desk 05/18/06 06:18:23 PM EDT

Flexstore is a traditional Shopping Cart application. In this tutorial, we create two modules: The administration module is an internal application used to maintain the product database. You use the administration module to create, update, and delete products. The store module is a customer-facing application. Customers use the store module to browse and filter the product catalog.

SYS-CON News Desk 05/18/06 05:36:13 PM EDT

Flexstore is a traditional Shopping Cart application. In this tutorial, we create two modules: The administration module is an internal application used to maintain the product database. You use the administration module to create, update, and delete products. The store module is a customer-facing application. Customers use the store module to browse and filter the product catalog.

@ThingsExpo Stories
SYS-CON Events announced today that Ryobi Systems will exhibit at the Japan External Trade Organization (JETRO) Pavilion at SYS-CON's 21st International Cloud Expo®, which will take place on Oct 31 – Nov 2, 2017, at the Santa Clara Convention Center in Santa Clara, CA. Ryobi Systems Co., Ltd., as an information service company, specialized in business support for local governments and medical industry. We are challenging to achive the precision farming with AI. For more information, visit http:...
High-velocity engineering teams are applying not only continuous delivery processes, but also lessons in experimentation from established leaders like Amazon, Netflix, and Facebook. These companies have made experimentation a foundation for their release processes, allowing them to try out major feature releases and redesigns within smaller groups before making them broadly available. In his session at 21st Cloud Expo, Brian Lucas, Senior Staff Engineer at Optimizely, will discuss how by using...
In this strange new world where more and more power is drawn from business technology, companies are effectively straddling two paths on the road to innovation and transformation into digital enterprises. The first path is the heritage trail – with “legacy” technology forming the background. Here, extant technologies are transformed by core IT teams to provide more API-driven approaches. Legacy systems can restrict companies that are transitioning into digital enterprises. To truly become a lead...
SYS-CON Events announced today that Daiya Industry will exhibit at the Japanese Pavilion at SYS-CON's 21st International Cloud Expo®, which will take place on Oct 31 – Nov 2, 2017, at the Santa Clara Convention Center in Santa Clara, CA. Ruby Development Inc. builds new services in short period of time and provides a continuous support of those services based on Ruby on Rails. For more information, please visit https://github.com/RubyDevInc.
SYS-CON Events announced today that CAST Software will exhibit at SYS-CON's 21st International Cloud Expo®, which will take place on Oct 31 - Nov 2, 2017, at the Santa Clara Convention Center in Santa Clara, CA. CAST was founded more than 25 years ago to make the invisible visible. Built around the idea that even the best analytics on the market still leave blind spots for technical teams looking to deliver better software and prevent outages, CAST provides the software intelligence that matter ...
As businesses evolve, they need technology that is simple to help them succeed today and flexible enough to help them build for tomorrow. Chrome is fit for the workplace of the future — providing a secure, consistent user experience across a range of devices that can be used anywhere. In her session at 21st Cloud Expo, Vidya Nagarajan, a Senior Product Manager at Google, will take a look at various options as to how ChromeOS can be leveraged to interact with people on the devices, and formats th...
SYS-CON Events announced today that Yuasa System will exhibit at the Japan External Trade Organization (JETRO) Pavilion at SYS-CON's 21st International Cloud Expo®, which will take place on Oct 31 – Nov 2, 2017, at the Santa Clara Convention Center in Santa Clara, CA. Yuasa System is introducing a multi-purpose endurance testing system for flexible displays, OLED devices, flexible substrates, flat cables, and films in smartphones, wearables, automobiles, and healthcare.
SYS-CON Events announced today that Dasher Technologies will exhibit at SYS-CON's 21st International Cloud Expo®, which will take place on Oct 31 - Nov 2, 2017, at the Santa Clara Convention Center in Santa Clara, CA. Dasher Technologies, Inc. ® is a premier IT solution provider that delivers expert technical resources along with trusted account executives to architect and deliver complete IT solutions and services to help our clients execute their goals, plans and objectives. Since 1999, we'v...
Enterprises have taken advantage of IoT to achieve important revenue and cost advantages. What is less apparent is how incumbent enterprises operating at scale have, following success with IoT, built analytic, operations management and software development capabilities – ranging from autonomous vehicles to manageable robotics installations. They have embraced these capabilities as if they were Silicon Valley startups. As a result, many firms employ new business models that place enormous impor...
SYS-CON Events announced today that Massive Networks, that helps your business operate seamlessly with fast, reliable, and secure internet and network solutions, has been named "Exhibitor" of SYS-CON's 21st International Cloud Expo ®, which will take place on Oct 31 - Nov 2, 2017, at the Santa Clara Convention Center in Santa Clara, CA. As a premier telecommunications provider, Massive Networks is headquartered out of Louisville, Colorado. With years of experience under their belt, their team of...
SYS-CON Events announced today that Taica will exhibit at the Japan External Trade Organization (JETRO) Pavilion at SYS-CON's 21st International Cloud Expo®, which will take place on Oct 31 – Nov 2, 2017, at the Santa Clara Convention Center in Santa Clara, CA. Taica manufacturers Alpha-GEL brand silicone components and materials, which maintain outstanding performance over a wide temperature range -40C to +200C. For more information, visit http://www.taica.co.jp/english/.
SYS-CON Events announced today that TidalScale, a leading provider of systems and services, will exhibit at SYS-CON's 21st International Cloud Expo®, which will take place on Oct 31 - Nov 2, 2017, at the Santa Clara Convention Center in Santa Clara, CA. TidalScale has been involved in shaping the computing landscape. They've designed, developed and deployed some of the most important and successful systems and services in the history of the computing industry - internet, Ethernet, operating s...
SYS-CON Events announced today that MIRAI Inc. will exhibit at the Japan External Trade Organization (JETRO) Pavilion at SYS-CON's 21st International Cloud Expo®, which will take place on Oct 31 – Nov 2, 2017, at the Santa Clara Convention Center in Santa Clara, CA. MIRAI Inc. are IT consultants from the public sector whose mission is to solve social issues by technology and innovation and to create a meaningful future for people.
SYS-CON Events announced today that IBM has been named “Diamond Sponsor” of SYS-CON's 21st Cloud Expo, which will take place on October 31 through November 2nd 2017 at the Santa Clara Convention Center in Santa Clara, California.
SYS-CON Events announced today that TidalScale will exhibit at SYS-CON's 21st International Cloud Expo®, which will take place on Oct 31 – Nov 2, 2017, at the Santa Clara Convention Center in Santa Clara, CA. TidalScale is the leading provider of Software-Defined Servers that bring flexibility to modern data centers by right-sizing servers on the fly to fit any data set or workload. TidalScale’s award-winning inverse hypervisor technology combines multiple commodity servers (including their ass...
Join IBM November 1 at 21st Cloud Expo at the Santa Clara Convention Center in Santa Clara, CA, and learn how IBM Watson can bring cognitive services and AI to intelligent, unmanned systems. Cognitive analysis impacts today’s systems with unparalleled ability that were previously available only to manned, back-end operations. Thanks to cloud processing, IBM Watson can bring cognitive services and AI to intelligent, unmanned systems. Imagine a robot vacuum that becomes your personal assistant tha...
Widespread fragmentation is stalling the growth of the IIoT and making it difficult for partners to work together. The number of software platforms, apps, hardware and connectivity standards is creating paralysis among businesses that are afraid of being locked into a solution. EdgeX Foundry is unifying the community around a common IoT edge framework and an ecosystem of interoperable components.
As popularity of the smart home is growing and continues to go mainstream, technological factors play a greater role. The IoT protocol houses the interoperability battery consumption, security, and configuration of a smart home device, and it can be difficult for companies to choose the right kind for their product. For both DIY and professionally installed smart homes, developers need to consider each of these elements for their product to be successful in the market and current smart homes.
Infoblox delivers Actionable Network Intelligence to enterprise, government, and service provider customers around the world. They are the industry leader in DNS, DHCP, and IP address management, the category known as DDI. We empower thousands of organizations to control and secure their networks from the core-enabling them to increase efficiency and visibility, improve customer service, and meet compliance requirements.
With major technology companies and startups seriously embracing Cloud strategies, now is the perfect time to attend 21st Cloud Expo October 31 - November 2, 2017, at the Santa Clara Convention Center, CA, and June 12-14, 2018, at the Javits Center in New York City, NY, and learn what is going on, contribute to the discussions, and ensure that your enterprise is on the right path to Digital Transformation.