Using a Zend view helper inside a partial

When rendering a page using one or more partials, I often need to call a helper to do some extra stuff for me. One caveat I found was, that the view variables was not available in my helper. After some …

Tagged , | 1 Comment

Problems connecting to unix:///var/mysql/mysql.sock

In this post I’ll go through fixing the problems with PHP and connecting to your local mysql install, using “localhost”.

The problems began a while back, with lots of errors in my apache error log saying:
[error] [client ::1] PHP Warning: mysql_connect(): [2002] No such file or directory (trying to connect via unix:///var/mysql/mysql.sock) in …

Tagged , , , | 3 Comments

Using rails and respond_to to include nested data

I want to display data from a nested table in my XML output using respond_to. I browsed the docs a bit and it seems :include is the way to go. However I had some problems getting this to work properly.

I have two models (customer and user) that are linked together. When I fetch the data for a single user, I want my xml output to include the customer data.

Tagged , , , | Leave a comment

Handle different environments with PHP

Being both a Rails and PHP developer, I’m often lacking a few things when I’m switching from Rails to PHP.

One of the things I miss the most, is the different environments that Rails has, which makes testing, developing, staging and production environments easy.
However, I found a way to do this in PHP as well, without using frameworks like Zend, CakePHP etc.

Tagged , , , | Leave a comment

MySQL 5.5, Mac OS X and startup item security error

A few days ago I got a shiny new macbook at work and I needed to install my dev environment again.

I came across a few problems when installing the new MySQL community server package though, which had been upgraded to 5.5 instead of the 5.1 release I had on my old Mac.

Tagged , | 2 Comments

Rails plugin development using WebMock

I had a few problems getting WebMock working with my rails 3 setup.

When I used webmock in my rails 3 app, the tests ran and all was nice.
But when I wanted to create a plugin using the exact same code as I just tested inside my rails app, I went into some problems.

To start, I created a new plugin using

rails generate plugin myclient

The files were generated and all seemed fine.

Tagged , , , | Leave a comment

Read more, continue reading, and how to easily fix it using WP

Yesterday I updated my grayish blog theme to a new blue and white theme, with more whitespace and less constraints.
While the new theme is isn’t perfect, I shined my website up a bit and it seems nice.

However, scrolling through my twitter list today, I read a blog post by Karan over at mardahl.dk, where she discusses the usage of “Read more” and “Click here” links on webpages. (Direct link to the blog post here).

This made me investigate what my own website was doing, and while the wording was a bit different, I had the same usability problem she describes in the blog post (you should really read it). People tend to overlook the wording, since lots and lots of advertisements use it. So when I use excerpts on my blog front page, and use the wording “Continue reading”, I’m actually scaring the user off, because my message will be misunderstood.

Tagged , , | 2 Comments

Windows clients with CUPS and Samba

After starting my new job, I battled a bit with getting a printer/scanner working on the local network. The fileserver was a mess as well… a real mess. My boss gave me permission to install linux on it (since I …

Tagged , , | Leave a comment

Making a Cafe Latté without a “do it all” machine

As you properly know, if you know me in real life, “I love coffee”.
(I also like tea though, but that’s a whole different story.)

Today when I wanted to make me a Latté, I thought to myself:
Why not tell other people how it’s done, so they also can enjoy a Cafe Latté without buying an expensive espresso machine.

Tagged , | Leave a comment

Using form_tag and collection_select with Rails3

After being away from rails for a while, i’m coming back en version 3 to check it all out again.

I had a problem with how to create a simple select, using the FormHelper.

I had two models, a user and a customer. They are defined as follows:

class User < ActiveRecord::Base
  belongs_to :customer
end
class Customer < ActiveRecord::Base
  has_many :users
end
Tagged , | Leave a comment