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">
<html>
   <head>
      <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>
    </head>
  <body>
      <%= @content_for_layout %>
  </body>
</html>

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

  def index
     render :layout => "ext"
  end

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

Posted in extjs, ruby on rails | Tagged , , , , | 3 Comments

Installing native Postgres gem for ruby

Recently did wonder about how to replace the slow postgres-pr library
with the native postgres version. Unfortuately the native client is not
that easy to install, especially without having cygwin installed.

You’ll need the postgres installation files for windows, best is the
zipped version without the installier, for example
postgresql-8.2.5-1-binaries-no-installer.zip, as you only need to copy
a few files out of it.

Then you need to use gem to install the postgres extension:

c:\>gem install ruby-postgres
..
2. ruby-postgres 0.7.1.2006.04.06 (mswin32)
..
> 2

(choose the latest mswin32 build)

Usually everything should be done now, but wait, testing it with:

c:\> irb
irb(main):001:0> require 'postgres'

gives an error ! You need to go back to the postgres installer file and
copy a couple of libraries to the ruby “bin” file (for example in
c:\ruby\bin\)

  • comerr32.dll
  • krb5_32.dll
  • libeay32.dll
  • libiconv-2.dll
  • libintl-2.dll
  • libpq.dll
  • ssleay32.dll

Don’t overwrite any files if they already exist in the ruby directory !

Now its time to try it out again:

C:\>irb
irb(main):001:0> require 'postgres'
=> true
irb(main):002:0>

Voila ! We have a native postgres client library installed and can use the advanced features like large object access.

Posted in postgresql, ruby on rails | 2 Comments