using extjs in rails part 1

Recently i came across a very nice javascript gui library called extjs It offers many nice advanced gui function such as grids, combo boxes, modal dialogs and so on. Right now i’m trying to create some basic bindings between RoR and extjs and will continue to write about my progress here.

First we need to copy some files from the current extjs 2.0 Distribution into our new rails project, namely ext-all.css into stylesheets, ext-base.js (found in adapter/ext/ext-base, could be replaced with the prototype adapter if you still want to use prototype) and ext-all.js into the javascripts directory.

Now i created a basic layout file called ext.rhtml which acts as a basic skeleton for our apps:

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
      <title><%= @title.to_s %></title>
      <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
      <link rel="stylesheet" type="text/css" href="/stylesheets/ext-all.css" />
      <script type="text/javascript" src="/javascripts/ext-base.js"></script>
      <script type="text/javascript" src="/javascripts/ext-all.js"></script>
      <%= @content_for_layout %>

Now we can create an controller and put some basic methods in it:

  def index
     render :layout => "ext"

This will render the index of the controller with the newly created ext layout. In Part 2 we will look into creating some basic hello world application with it

This entry was posted in extjs, ruby on rails and tagged , , , , . Bookmark the permalink.

3 Responses to using extjs in rails part 1

  1. martin.rehfeld says:

    You might be interested in this as well…

    Recently I played with Ext and Rails myself and documented the effort.

    This demonstrates basic solutions for Rails integration and features a “soon-to-be-announced” Ext Scaffold Generator plugin for Rails – a preview version is available on Rubyforge.

  2. christocracy says:

    I’ve been using Ext since V0.33. it’s really great and works well with Rails.

    I have a blog dedicated to Ext / Rails integration

    and some google code

  3. christocracy says:

    This guy has a blog about Ext / Rails, as well:

Leave a Reply