2006-03-16

Switch » Bluefish

RadRails is fine but it eats memory like peanuts. From yesterday I am giving Bluefish a try.

It has some annoying bugs^h^hfeatures like awkward syntax highlighting issues or problems with displaying directory tree. But those are things I can either fix or live with.

So why am I switching to Bluefish? Because it is blazing fast and uses tenfold less memory than Eclipse+RadRails

2006-03-12

Where to store Rails session data?

During first days of development I didn't care much for session data. Rails put those in files in /tmp by default - and that was fine with me. Sometimes stale sessions were causing problems with my applications but a quick cleanup was all I needed.

Those session related errors got more annoying when I deployed my application on Textdrive with it's full of Rails data /tmp directory. So I moved to database-based session storage.

But for some reason recently I started to see new kind of session related errors. When application was reloaded in development mode it often failed in a very strange place - while re-setting routes. Guess there must have been some incompatibilities between Edge Rails database session storage and Engine dependency handling. Luckily Edge Rails also introduced cleanups in file-based session storage. So once again I am storing all my session data in file system.

Now the question is: Was this trip really necessary?

2006-03-10

Stupid Monkey

Cannot open index.html

The filename "index.html" indicates that this file is of type "HTML document". The contents of the file indicate that the file is of type "XML document". If you open this file, the file might present a security risk to your system.

Do not open the file unless you created the file yourself, or received the file from a trusted source. To open the file, rename the file to the correct extension for "XML document", then open the file normally. Alternatively, use the Open With menu to choose a specific application for the file.

Talk about overacting. I love Gnome but sometimes it just sucks...

Rcss Changes

Rcss is going through a major rework. It has been Enginised and right now supports server-side includes.

You can include a file in your CSS files with following statement:


@server include(common.css)

All constants from included file are evaluated so it is a perfect way to provide common values for several CSS files.

Code is currently available in Subversion repository: svn://rubyforge.org/var/svn/rcss/trunk/rcss

You need to have Engines plugin installed and following route added to your routes.rb:


  map.connect('stylesheets/:id', :controller => 'stylesheets', :action => 'show')

Then just move your CSS files from public/stylesheets to app/views/stylesheets

2006-03-06

Dynamic template_root

I am currently developing a multi-site application. One of the features is that it picks layouts and page templates basing on the domain. I was trying to put everything domain-related in a separate directory like this:


RAILS_ROOT
 \- sites
    |- domain_a
    |  |- layouts
    |  |- templates
    |  \- stylesheets
    |
    \- domain_b

My first guess was to set the @@template_root of the controller from within before_filter. It didn't worked as desired.

Second attempt was to actually override the method self.template_root in the controller. It seemed to work fine - but only for default site.

Now the real problem is that Controller.template_root is read only once, when the controller is instantiated. In fact it is read before it can be set to something meaningful in before_filter.

I have solved this problem by using render :file => path and not relying on template_root at all. Another possible solution might be to modify the @@template.base_path from your controller, but I have not looked at this possibility yet.

2006-03-01

Fedora and Ruby MySQL Bindings

Yesterday I tried to install mysql gem. It refused to install complaining about missing mysqlclient library. Which WAS present.

It turned out that it was enough to tell gem where to find mysql_config command:


$ gem install mysql -- --with-mysql-config=/usr/bin/mysql_config

And now for the best part: Fedora provides MySQL bindings by itself through ruby-mysql package. And it was already installed on my system. DOH.


$ gem uninstall mysql
$ yum install ruby-mysql