Setting up PostgreSQL 8.x with Ruby 1.8.6 on Rails 2.3.4
Nov0
PostgreSQL is a:
Sophisticated open-source Object-Relational DBMS supporting almost all SQL constructs, including subselects, transactions, and user-defined types etc…
The Problem
-
You have just installed PostgrelSQL.
-
You have generated your rails app
rails myApp -d postgresql
-
You try to run the server
ruby script/server
-
You add your DB details in config/database.yml and you notice this note.
On Windows:
# gem install ruby-postgres # Choose the win32 build. # Install PostgreSQL and put its /bin directory on your path.
-
Install that gem
gem install ruby-postgres
* I didn’t get prompted to choose the win32 build but it all installs well.
From now on, to cut this short, few of the errors that you might encounter:
Please install the postgres adapter: 'gem install activerecord-postgres-adapter'
if you try to install that gem you will get this Error
ERROR: could not find activerecord-postgres-adapter locally or in a repository
So try to install this gem instead “ruby-postgres” like i mentioned before.
Another prompt you might get is when trying to run the server:
The ordinal 284 could not be located in the dynamic link library SSLEAY32.dll
The Solution
-
Copy both “ssleay32.dll” and “libeay32.dll” from Postgresql bin directory. On my machine that’s:
C:\Program Files\PostgreSQL\8.4\bin
-
and put them in Ruby’s bind directory. On my machine that’s:
C:\Ruby\bin
- And it works!
* It seems those files were already in Ruby’s bin folder, so overwrite the ones there.
Installing mysql gem on MAC OS + XAMPP + Rails 2.3
Nov0
If you are on a MAC, using the easy going XAMPP and need that rails app to get up and running using mysql, then read on.
So Rails 2 does not come with the mysql gem installed.
You run:
gem install mysql
and to your shock you get:
ERROR: Error installing mysql:
ERROR: Failed to build gem native extension.
And in your log you see:
no such file to load — mysql
Before you do anything, make sure you download the “developer package” from XAMPP website.
Then in your terminal run this command:
sudo env ARCHFLAGS=”-arch i386″ gem install mysql — –with-mysql-dir=/Applications/XAMPP/xamppfiles/lib/mysql –with-mysql-lib=/Applications/XAMPP/xamppfiles/lib/mysql/ –with-mysql-include=/Applications/XAMPP/xamppfiles/include/mysql/
And finally, it worked!
File browser for Ruby on Rails
Jun16
I have spent all day yesterday looking for a good(any) Ruby on Rails file explorer or browser for a web application but did not find anything. Few people mentioned Boxroom which looks great except it is an entire web application.
Then I bumped to jQuery File Tree.
jQuery File Tree is a configurable, AJAX file browser plugin for jQuery. You can create a customized, fully-interactive file tree with as little as one line of JavaScript code.
It has a Ruby connector but not a Rails one, so I decided to write a connector that I can use with Rails 2.3.
I will show you in very easy steps how to setup this up.
Download the source code.
Download a demo.
- Assuming you have your Rails app created and ready. Open the source zip file and copy both ‘app’ and ‘public’ folders into your application’s root.
- Next, in the head tag of your layout, add the javascript libraries needed and the jQuery File Tree CSS file.
<script type="text/javascript" src="javascripts/jquery.js"></script> <script type="text/javascript" src="javascripts/jquery.easing.js"></script> <script type="text/javascript" src="javascripts/jqueryFileTree.js"></script> <link rel="stylesheet" href="stylesheets/jqueryFileTree.css" type="text/css"/>
- Right under that add this style for the page:
11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28
<style type="text/css"> body { background-color:#EEEEEE; font-family:Verdana,Arial,Helvetica,sans-serif; font-size:11px; padding:15px; } .demo{ background-color:#FFFFFF; border-color:#BBBBBB #FFFFFF #FFFFFF #BBBBBB; border-style:solid; border-width:1px; height:400px; overflow:scroll; padding:5px; width:200px; } </style>
- In the body tag, create the div that will carry the File Tree explorer.
38 39
<h2>jQuery File Tree for Ruby on Rails</h2> <div id="fileTree" class="demo"></div>
- Now to create our fileTree using jQuery, we add this script in the head tag:
29 30 31 32 33 34 35
<script type="text/javascript"> $(document).ready( function() { $('#fileTree').fileTree({ root: '', script: 'jqueryfiletree/content' }, function(file) { alert(file); }); }); </script>
@ line 31, you will notice we passed root and script variables to the fileTree method.
root = the folder you wish to browse, in this case it is an empty string, to point to our public folder. If you wish to point to the images folder, then you type root:”images/”
script= controller/method - Now open config/routes.rb and add this line:
2
map.resources :jqueryfiletree
- DONE! Run the server and you will see the File Tree browser.

