Posts filed under 'Announcements'

Welcome!

Martin Rehfeld is blogging on GL Networks Inside about technical background, tools, tips, news and stories related to the work of GL Networks - networked consulting services and IT solutions since 1992.

Recommend Martin Rehfeld on Working With RailsMartin is passionate about Ruby on Rails. He has published several Rails plugins and regularly gives talks at Rails related events. If you like Martin’s work, consider recommending him on Working With Rails.

Add comment March 11th, 2006

Announcing: Ext Scaffold Reloaded Plugin for Ruby on Rails

Ext Scaffold just got “Reloaded” for Christmas. Never heard of Ext Scaffold? Ok, so first things first:

The Ext Scaffold Generator Plugin is a drop-in replacement for Rails’ standard Scaffold Generator. Accepting the very same options, it will generate views using data grid and form components from the Ext JS Javascript GUI framework as well as a controller acting as an Ext-compatible JSON web service. The generated code can be used as a starting point for further implementation and outlines solutions on how to integrate the Ext JS library with Rails as a backend.

When Ext Scaffold was first released earlier this year, it was a rather experimental shot at Ext/Rails integration. It still received a lot of great feedback, and more importantly it helped me gather things I would do different next time.

Ext Scaffold Reloaded is the fruit of all lessons learned since the first release, if you will. So without further ado, here are the top enhancements:

  1. One-page user interface: The Grid and the form are integrated into one single page. As no page reload is necessary when switching between grid and form, the interfaces is much more responsive.
  2. No more magic: The formerly introduced view helpers are gone. While they made the view code look very simple and elegant, they more so obfuscated what was actually going on.
  3. Easy refinement: All Javascript code is now generated explicitly and thus can be easily tweaked and refined to one’s needs.

Ext Scaffold also found its new home over at github. So give it a spin and let me know what needs to be radically different in the Revolutions release ;-) .

Recommend Martin Rehfeld on Working With RailsIf you like this plugin, please consider recommending me on Working with Rails. Thank you!

Related Posts

4 comments December 24th, 2008

Bridging Rails to Amazon SimpleDB using ActiveResource

With SimpleDB, Amazon added the long-awaited database-like service to it’s web services portfolio. A database was the one thing missing for building a complete web hosting stack with Amazon’s services.

Using SimpleDB together with Ruby on Rails was the thing I immediately wanted to try. Some problems had to be dealt with first:

  1. Amazon does not provide any Ruby code for SimpleDB access
  2. SimpleDB has quite some limitations as detailed in a previous post

As Lars Schenk outlines on his Blog at least three different projects on RubyForge are addressing problem number one - only one of them has actual code, though. And that is aws-sdb by Tim Dysinger from Hawaii.

OK, using Tim’s aws-sdb gem, one can get access to SimpleDB using Ruby. But using SimpleDB as a drop-in-replacement for a relational database and connecting Rails’ ActiveRecord to it would require a fairly complex adapter - I am not sure, if this can be done at all, actually.

Looking at Rails, another interface comes to mind: ActiveResource. ActiveResource was written to connect model objects to RESTful web services as their datastore. That sounds like a fit. The APIs are different, but the functionality needed by ActiveResource can be provided by SimpleDB - it’s all just CRUD after all.

All that’s needed would be a adapter, a proxy, a proxy server? Yes, that’s right. As it turned out, it’s not too hard to write one, so here it is :-)

Announcing AWS SDB Proxy

My AWS SDB Proxy is a HTTP proxy server bridging ActiveResource calls from Rails to Amazon’s SimpleDB Web Service allowing it to be used as a storage backend for Rails applications.

The proxy will listen for web service calls initiated by ActiveResource models and forward the requests to SimpleDB using the aws-sdb gem.

Install the AWS SDB Proxy Plugin from RubyForge as usual:

script/plugin install http://rug-b.rubyforge.org/svn/aws_sdb_proxy

Then follow the instructions provided in the README.

Features and Limitations

SimpleDB (and thus AWS SDB Proxy) do not use any pre-defined schema. Every record can potentially have different attributes. SimpleDB also has no data types associated with it’s attributes, all data will be stored as strings.

AWS SDB Proxy adds a special _resource attribute, allowing storage of multiple models within the same SimpleDB domain. Record ids are generated using a SHA512 hash function to make key collisions extremely unlikely.

Recommend Martin Rehfeld on Working With RailsIf you like this plugin, please consider recommending me on Working with Rails. Thank you!

Related Posts

12 comments January 20th, 2008

Announcing: Ext Scaffold Generator Plugin for Rails

Ext Scaffold Generator Plugin GUI Screenshot.png

Update (12-2008): Ext Scaffold Reloaded has been released. While the version discussed in this post is still available, I strongly suggest looking into the latest version over at github/ext_scaffold. The Reloaded edition offers a richer UI, better performance and can be customized much easier — it is the fruit of all lessons learned since the first release, if you will. Read the announcement.

The Ext Scaffold Generator Plugin can be viewed as a drop-in replacement for Rails’ standard Resource Generator. Accepting the very same options, it will generate views using data grid and form components from the Ext JS Javascript GUI framework as well as a controller acting as an Ext-compatible JSON web service. The generated code can be used as a starting point for further implementation and outlines solutions on how to integrate the Ext JS library with Rails as a backend.

What it does not do

Ext JS is huge. It provides just about any component for developing Rich Internet Applications. The Ext Scaffold generator only uses a very limited subset of Ext JS. It includes some view helper methods to generate Javascript code, but these helpers are not really meant to be used in other contexts. IMHO it is better to code the Javascript in views by hand.

Any attempt of providing helpers for even a subset of the Ext functionality seemed like a dead-end approach to me. For further refinement of your application I suggest looking at the generated JS code and change it to suit your needs.

Features and Concepts

The way Ext JS works is to code all GUI components and interactions in Javascript. These components will then interact with a datastore backend via web service requests (either JSON or XML formatted).

The Ext Scaffold Generator Plugin provides a custom MIME type alias :ext_json to be able to handle requests from the Ext frontend separately. The generated controllers show how to do this.

To make data delivery to the Ext frontend easy, the plugin extends the Array and ActiveRecord::Base classes to provide a to_ext_json method. Here’s a simplified example of a potential index method in a PostsController:

# GET /posts
# GET /posts.ext_json
def index
  respond_to do |format|
    format.html     # index.html.erb (will fire ext_json request)
    format.ext_json { render :json => Post.find(:all).to_ext_json }
  end
end

to_ext_json will also format validation error messages attached to ActiveRecord::Base objects. This can be used to provide server-side validations additionally to Ext’s own client-side validation features in forms. Another simplified example using our fictitious Post resource:

# Model
class Post < ActiveRecord::Base
  validates_presence_of :title
end

# Controller
class PostsController < ApplicationController
# ...
# POST /posts
  def create
    @post = Post.new(params[:post])
    if @post.save
      flash[:notice] = 'Post was successfully created.'
      render(:update) {|page| page.redirect_to posts_url }
    else
      render :json => @post.to_ext_json(:success => false)
  end
end
# …
end

Installation

script/plugin install http://rug-b.rubyforge.org/svn/ext_scaffold

After the plugin has been installed, download the Ext Javascript framework from http://extjs.com/download and unzip it into #{RAILS_ROOT}/public/ext. The plugin was tested against version 2.0.1 of the Ext framework.

Usage Exmples (call without params for help)

./script/generate ext_scaffold post title:string body:text published:boolean
./script/generate ext_scaffold purchase order_id:integer amount:decimal

Recommend Martin Rehfeld on Working With RailsIf you like this plugin, please consider recommending me on Working with Rails. Thank you!

Related Posts

57 comments January 18th, 2008

Amazon SimpleDB web service complementing the EC2 compute cloud

Amazon Web Services yesterday announced its latest creation: SimpleDB. SimpleDB is a database-like storage service for structured data. It complements EC2 (the Elastic Compute Cloud) and S3 (the Simple Storage Service), potentially enabling web applications to run solely on Amazon’s service stack. SimpleDB has a couple of limitations compared to traditional relational databases, the most important being:

  • No joined queries against multiple tables (or domains, as Amazon puts it)
  • No transactions protecting multiple updates
  • No instant data updates, i.e. you might get “old” data when you query data that was updated very recently

We will have to wait and see what kind of applications SimpleDB can support regardless of these limitations. On the plus side we get the usual benefits of Amazon’s Web Services:

  • very good scalability
  • high availability
  • low cost / pay for usage

At GL Networks we will definately take a close look at SimpleDB, possibly bridging it to Rails via the ActiveResource framework.

SimpleDB will enter a closed beta program very soon.

Related Post: Amazon EC2 - The Future of (Rails-) Hosting?

Add comment December 15th, 2007


Posts by Category