Sunday, August 24, 2008

Ext JS 2.0 and rails

I've always wanted a nice Javascript library that I could use as a framework for everything I build. Prototype and Script.a.cul.ous are nice but not sufficient to give the look and feel of a desktop app. So I've decided to implement Ext JS for my solution and to share this experience. There are basically 2 solutions if you want to integrate ext js in your application, the usage of a plugin called ext-scaffold (very easy to use) or the hard-way (manual coding).

Note : The current Rails 2.1 changes the way that rails renders json format. Therefore the plugin ext-scaffold will cease to work out of the box with rails 2.1. This plugin is still functionning perfectly with rails 2.0.2 and remains the fastest way to start playing with ext js and rails.

The plugin gives a good starting point and is functional for simple CRUD application. if you are looking for a quick way to provide a user interface to your tables without exposing the database, it's perfect.

From there, the need to do more complex things arise and then, you guessed it, it's time for the manual coding.

SQL Server 2008 and active records

Some important things to know when working with Active records and SQL Server :

1. The ID field has Integer as default data type

2. The ID field is automatically created with an Identity specification with the following values :
- Identity Increment 1
- Identity Seed 1

3. The created_at field does not get a default value (eg. Getdate() would have been nice !). Thus if you don't rely exclusively on the active record to populate this field, it is recommended to add this default value.

4. The updated_at field does get the same value as created_at first. It is then updated while created_at remains unchanged.