Posts filed under 'Tools'

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

13 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

59 comments January 18th, 2008

Radio with Rails Pet Project now on Google Code

A little pet project I have been developing for a while starred in the last couple of issues of the German Entwickler-Magazin (~ developer’s magazine). It is a Ruby on Rails application called Radio and can record scheduled audio streams from the internet and provide you with a local RSS feed of the recordings in MP3 format. Cool to carry around radio recordings on your iPod ;-)

Screenshot Radio English

The source is published under a GPL license, so you can grab radioonrails from Google Code now and do whatever you want with it (almost).
By the way, the GUI is available in German and English and will honor your browsers preferences in that respect.

Feedback is very much appreciated! Just drop me a line at martin.rehfeld@glnetworks.de

Add comment April 21st, 2007

Microformats have arrived in Firefox 1.5 / Greasemonkey 0.6

When I first heard about Microformats, I immediately was convinced that they are the way to go within the Semantic Web. There just were no practical tools around to display and use them within my browser, which happens to be a recent Firefox on Linux.
Well, there is microformat-find-gm5, based on the work of David Janes, now. Get it while it’s hot!

Background

On Web pages you will often find references to individuals, locations and calendar dates. Microformats are a way to embed these (and other) content elements within a webpage, so a machine can read and process them. This is what the microformat-find-gm5 scripts does. It looks for supported Microformats on a Web page, tags them with little images having a context menu to provide useful functions for the given content. That might be ‘Add to address book’ or ‘Add to Calendar’, ‘Show on Google Maps’ and so on. More and more webpages and blogs are using Microformats, so look out for these little tags…

hCard tag

Download and Installation

References to other Microformat tools

3 comments June 5th, 2006

WeatherTime Screensaver Plugin for Slimserver

Upgrade your network music player to a weather station now! Get the free WeatherTime Screensaver Plugin for Slimserver - brought to you by GL Networks Inside.

WeatherTime is a screensaver to show graphical weather forecasts along with the current date and time on Slim Devices great network music players SLIMP3 and Squeezebox. It is a intended replacement for the standard DateTime screensaver.

Neat Features

  • fetches weather data online from Wunderground.Com
  • displays graphical icons for weather conditions along with weather data
  • supports both metric and imperial units
  • supports English, German, French (contributed by Daniel Born) and Dutch (contributed by Willem Oepkes and Mark Ruys) menus and weather infomation
WeatherTime screenshot current conditions...
WeatherTime screenshot forecast...


Installation

  • For the 7.x series of Squeezecenter download WeatherTime 2.2.1 (zip) and visit the project’s page on Googlecode for further instructions.
  • For the 6.5 series of Slimserver download either WeatherTime 1.9.5 (zip) or WeatherTime 1.9.5 (tar.gz)
  • Extract the archive into the ‘Plugins’ directory of your Slimserver installation
  • Restart Slimserver
  • Activate the plugin and set up the WeatherTime options in Slimserver’s plugin settings
  • Activate WeatherTime as a screensaver for off-mode and/or on inactivity in your player settings. The easiest way to do this is the SlimServer web frontend (Player settings).

Hints and Tips

  • You can browse through the weather forecasts of the coming days with the up and down arrows on your remote.
  • You can manually start (e.g. not enabling it as a screensaver) WeatherTime from the Plugin menu of your player - press PLAY.
  • To avoid truncation of the date and time information, choose short display formats in Slimserver’s Server Settings -> Formatting. Even shorter date formats are available in WeatherTime’s plugin settings. You may also choose not to display the date at all.
  • Report issues and seek solutions at the Slim Devices Plugins Forum WeatherTime thread

Restrictions & Known Bugs

  • Needs a Squeezebox2 or better to show weather condition icons and detailed info, the SLIMP3 and SqueezeboxG devices will show text only information
  • Truncation of weather condition texts may occur occasionally for rather long texts

90 comments March 11th, 2006


Posts by Category