Month: March 2009

XFCE 4.6 makes it into Debian Experimental

Posted by on March 29, 2009

After a long long wait, Debian Experimental is finally blessed with XFCE 4.6. To install it you have to enable the experimental repository. Put this line in your /etc/apt/sources.list file somewhere:

#Debian Experimental
deb http://ftp.debian.org/debian/ experimental main non-free contrib



Next run an update and upgrade:

sudo apt-get update
sudo apt-get dist-upgrade


Finally, grab the XFCE 4.6 packages:
sudo apt-get install xfce4 -t experimental


There are a number of improvements in XFCE 4.6 but the big winner for me is the multiple selection of icons on the Desktop. Something that other DE (including LXDE) have been doing forever.

Autocomplete associated fields in Rails 2.3

Posted by on March 28, 2009

I recently had to use an autocomplete field and populate the associated form fields depending on the result. It's not that bad to do using javascript if you know what you're doing. The last part is the key of course. It took me a while to figure it out so I thought I'd share. So if you're using Ruby on Rails and want to pull it off, here's a step by step on how to do it.


First thing you need to do is install the autocomplete plugin for Rails as this functionality was removed from core quite a while ago:

ruby script/plugin install auto_complete


In this example we'll be working with a Charity model. We'll be grabbing the charity name using an autocomplete text box and filling in another field.

This assumes you have your form already set up correctly, so first get the text field with autocomplete set up:

<%= text_field_with_auto_complete :charity, :name %>


Next, let's observe that field:

<%= observe_field 'charity_name', :on => 'blur', :frequency => 0.50, :url => {:action => 'update_fields'}, :with => "'name=' + element.value"  %>


In our example we'll set up one more field which we'll have populated. Let's call it address:

<%= f.text_field :address %>


Remember that your field name may vary depending on how your form is setup. If unsure, use firebug or view the source of your form.

Lastly, let's get some controller code in the update_fields action. This is where we call our javascript.


def update_fields
@charity = Charity.find_by_name(params[:name])
if @charity.nil?
render :nothing => true
else
render :update do |page|
page['charity_address'].value = @charity.address
end
end


In the above example you can fill in as many associated fields as you'd like. You can also put the above into an RJS.. frankly that might be better but I like to have logic in my models first, then my controllers, and lastly in any views.

undefined method `use_transactional_fixtures=’ in Rails 2.3

Posted by on March 18, 2009

I'm trying to be better about testing these days so when I upgraded to Ruby on Rails 2.3 the other day I was a bit dismayed to be getting errors with my tests. They went something like this:


undefined method `use_transactional_fixtures='


Ug. I generated a new Rails 2.3 app to find out what was going on.


Turns out the problem is in the test_helper.rb file. You'll need to swap out the old class definition with this:

class ActiveSupport::TestCase


Once you do that your tests should run again (assuming they did before hand).

Quick Tip: Solve uninitialized constant ApplicationController in Rails 2.3

Posted by on March 16, 2009

If you've just upgraded your Rails stack to 2.3 you may be seeing a strange error:

uninitialized constant ApplicationController


Turns out, among the Major changes that came along with the latest Release of Ruby on Rails, there were a few minor ones too. One of those is that the application controller is no longer called application.rb Now it's referred to as application_controller.rb.

In effect, to solve this problem, just rename the file. Or, as Liam points out in the comments below, run:

rake rails:update



Be sure to update your server stack before deploying. Obviously if you rename the file to get it working on Rails 2.3 and upload to a Rails 2.2 server you'll be in trouble. Don't forget that Rails 2.3 also requires a new version of Phusion Passenger!

Useful font and tab tweaks for Iceweasel

Posted by on March 4, 2009

I had to erase my .mozilla folder today.. ran into a weird problem with gmail. Whenever I start off with Firefox/Iceweasel for the first time there are always some font adjustments I need to make in the about:config section. These settings generally match what ships by default in Windows. On the Linux side though these can vary depending on the distro. If you happen to have some font-rendering issues, try these settings:



font.size.variable.x-western: 16
font.size.fixed.x-western: 13
font.minimum-size.x-western: 0