I swore I wouldn't

Icon

Oh no, I'm blogging now?

Code Igniter was fun, sort of

My time with CodeIgniter was fun, but it’s time to switch back to Rails. I enjoyed the ability to really get in and handle some of the code the way that I preferred, but overall I found that I missed a lot of the automagical things that happen with Rails. The biggest shortcoming for me was the lack of a real ActiveRecord model. I might give it a shot where it seems appropriate in the future, but for now I’m going back to Rails.

The change you wanted was rejected – Rails Problem

I received the error “The change you wanted was rejected” after I moved a rails app from one host to another.

Looking into the log file, the following error appears:

ActionController::InvalidAuthenticityToken (ActionController::InvalidAuthenticityToken):
/usr/lib/ruby/1.8/mongrel/rails.rb:76:in `process'
/usr/lib/ruby/1.8/mongrel/rails.rb:74:in `synchronize'
/usr/lib/ruby/1.8/mongrel/rails.rb:74:in `process'
/usr/lib/ruby/1.8/mongrel.rb:159:in `process_client'
/usr/lib/ruby/1.8/mongrel.rb:158:in `each'
/usr/lib/ruby/1.8/mongrel.rb:158:in `process_client'
/usr/lib/ruby/1.8/mongrel.rb:285:in `run'
/usr/lib/ruby/1.8/mongrel.rb:285:in `initialize'
/usr/lib/ruby/1.8/mongrel.rb:285:in `new'
/usr/lib/ruby/1.8/mongrel.rb:285:in `run'
/usr/lib/ruby/1.8/mongrel.rb:268:in `initialize'
/usr/lib/ruby/1.8/mongrel.rb:268:in `new'
/usr/lib/ruby/1.8/mongrel.rb:268:in `run'
/usr/lib/ruby/1.8/mongrel/configurator.rb:282:in `run'
/usr/lib/ruby/1.8/mongrel/configurator.rb:281:in `each'
/usr/lib/ruby/1.8/mongrel/configurator.rb:281:in `run'
/usr/lib/ruby/1.8/mongrel/command.rb:212:in `run'

Rendering /vol/sites/site/public/422.html (422 Unprocessable Entity)

Some further investigation revealed that there was an issue with how rails 2.3.8 was handling cookies.  I stumbled upon the following fix at https://rails.lighthouseapp.com/projects/8994/tickets/4690.

I used Ken Collins’ fix of adding his mongrel.rb (http://gist.github.com/471663) to config/initializers and now all is well.

First Impressions of Code Igniter


Code Igniter Last night I was forced to start working with CodeIgniter, a PHP web-framework, and I have to say that so far I am enjoying the experience.

CodeIgniter provides a simple framework that allows you to quickly get an application up and running.  The learning curve (so far) has been very low.  I like web-frameworks for projects. I have done a number of projects in Ruby on Rails, and I have dabbled in Django. Those have been pleasant experiences, but I prefer PHP as my preferred development language for most projects due to a number of reasons (not interested in jumping into that holy war right now.)

Up to this point, if I wanted to use a PHP framework, my choices were Zend and CakePHP. Zend is a monster. I’m sorry, I know a lot of developers swear by Zend, but I’m not one of them. Nobody “quickly” picks up Zend. Zend is so incredibly dense/bloated/abstracted that debugging something becomes an exercise that is more time consuming than the original problem that you were trying to solve. CakePHP felt too much like I was pretending to be Ruby on Rails, and there were so many hoops to jump through. And it was frequently a little “too magical.”

After exploring these different options, I wrote my own framework that took the parts of Ruby on Rails that I enjoyed, but kept the flexibility and familiarity of PHP. I have been using this for over a year now and it has served me well. I was pleased to find that the structure of CodeIgniter was almost identical to the structure of my own framework. This has made it a very easy switch for me.

Read the rest of this entry »

Installing MySQL gem on OS X


I encountered the following error when installing the mysql gem on a shiny new Macbook Pro running OS X Leopard.

Note: I have ~/.gem set as my GEM_HOME and GEM_PATH to avoid needing to sudo


> gem install mysql
Building native extensions. This could take a while...
ERROR: Error installing mysql:
ERROR: Failed to build gem native extension.

/System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/bin/ruby extconf.rb
checking for mysql_query() in -lmysqlclient... no
checking for main() in -lm... yes
checking for mysql_query() in -lmysqlclient... no
checking for main() in -lz... yes
checking for mysql_query() in -lmysqlclient... no
checking for main() in -lsocket... no
checking for mysql_query() in -lmysqlclient... no
checking for main() in -lnsl... no
checking for mysql_query() in -lmysqlclient... no
checking for main() in -lmygcc... no
checking for mysql_query() in -lmysqlclient... no
*** extconf.rb failed ***
Could not create Makefile due to some reason, probably lack of
necessary libraries and/or headers. Check the mkmf.log file for more
details. You may need configuration options.

The workaround was fairly simple. Since I had installed MySQL from source the situation was resolved with a few command line options:


> export ARCHFLAGS="-arch x86_64"
> gem install mysql -- \
--with-mysql-dir=/usr/local/mysql \
--with-mysql-lib=/usr/local/mysql/lib \
--with-mysql-include=/usr/local/mysql/include \
--with-mysql-config=/usr/local/mysql/bin/mysql_config

Building native extensions. This could take a while...
Successfully installed mysql-2.8.1
1 gem installed

Installing MySQL from source on OS X

While MAMP has proven to be very convenient for doing local development, not having the MySQL header files around sometimes causes difficulty when it comes time to install/compile something that needs those header files to be in place.

Getting Ready
I always set up a src directory under my user account for these installations.

> cd ~
> mkdir src
> cd src

Download MySQL Community Edition
At the time of this writing, it could be found at http://mysql.mirrors.hoobly.com/Downloads/MySQL-5.1/mysql-5.1.45.tar.gz

Download this file into your src directory.

> curl -O http://mysql.mirrors.hoobly.com/Downloads/MySQL-5.1/mysql-5.1.45.tar.gz

Untar, configure, and install

> tar -xvzf mysql-5.1.45.tar.gz
> cd mysql-5.1.45
> ./configure --prefix=/usr/local/mysql --with-extra-charsets=complex \
--enable-thread-safe-client --enable-local-infile --enable-shared \
--with-plugins=innobase

> make
> sudo make install

> cd /usr/local/mysql
> sudo ./bin/mysql_install_db --user=mysql
> sudo chown -R mysql ./var
> cd ..

MAMP specific issue

Given that I had installed MAMP previously, I had modified my /etc/my.cnf to specify that the mysql.sock was located in /Applications/MAMP/tmp/mysql/mysql.sock. I modified this line to point to /usr/local/mysql/var/mysql.sock, and then set the sticky bit on the var directory.

> chmod 1777 /usr/local/mysql/var

There are other steps that can be added so that mysqld launches on startup, but I prefer to start it manually when it is needed.

Dealing with a trojan virus on dreamhost

I host a lot of simple sites on Dreamhost.  Imagine my surprise when I went to log into my control panel and was informed that google had listed one of my sites as being a suspected malware site.

The site that it referenced was a very rarely used site, that only housed a custom built app (more of a script than an actual app) so I was puzzled as to how this site could have become infected.

I logged into the host, and did a quick check of the directory structure, and immediately noticed some suspicious things. Read the rest of this entry »

Installing django with MySQL on OS X

I am experimenting with the django web-framework for a few projects at work.  I do the majority of my work in PHP or Java, but occasionally I like to play with Ruby on Rails, and decided that django deserved to have a look as well.

The first step in this process is to get django and the various components installed.

  • Python
  • EasyTools
  • MySql
  • MySqlDB
  • Django

Read the rest of this entry »

Alfresco installer won't launch

Struggled to find this answer when I installed Alfresco on our dev server.  We are running a 64 bit ubuntu installation, and when we try to launch the Alfresco installer, it does nothing.  There is no error, it doesn’t act like it’s working, nothing.  Searching around, I found the following forum that briefly mentions the need for ia32-libs.

Alfresco • View topic – Can’t start the linux community installer in Ubuntu 9.10-b6.

> sudo apt-get install ia32-libs

The problem is now solved.

I <3 Capistrano

I first heard about Capistrano when I was starting out with Ruby on Rails development.  At the time I did almost all of my work directly on the server and didn’t really need a way to deploy my application from dev to production.  Recently, however, I got tired of doing everything through Transmit+TextMate.  (I love both of these projects, but prefer to take full advantage of opening projects in TextMate.)  So I started doing my development locally and figured it was time to take advantage of Capistrano. Read the rest of this entry »