Rails on Tiger
Posted by Quinn at November 20th, 2006 2:40pm under web 0 Comments Permalink
Most times, I develop stuff on FreeBSD. But lately, I'm feeling like developing some stuff directly on my PowerBook. Over the last weekend, I tried Four Days on Rails for the second time. I kind of finished this a long time ago but not quite complete. It was on FreeBSD for the last time but this time on Mac OS X.
I basically followed instructions on this page: Building Ruby, Rails, LightTPD, and MySQL on Tiger to setup the development environment. This is a really nice page but I encountered a few problems or just one thing. So I thought I would like to share it with whoever is interested.
It explains about editing a ~/.bash_login file to modify PATH, shell environment variables. However, it never worked for me. It appears to be reading only the two files, /etc/profile and ~/.bash_profile when I login or whenever I launch a window of Terminal.app.
I have both fink and darwinports installed, which certainly automatically modiifed ~/.bash_profile files to something like below.
export PATH=/opt/local/bin:/opt/local/sbin:$PATH export DISPLAY=:0 test -r /sw/bin/init.sh && . /sw/bin/init.sh
In this situation, if I type echo $PATH in the Terminal window. The result would be like:
$ echo $PATH /sw/bin:/sw/sbin:/opt/local/bin:/opt/local/sbin:/bin:/sbin:/usr/bin:/usr/sbin:/usr/local/mysql/bin:/usr/X11R6/bin
I edited both root and my primary user's ~/.bash_profile files to:
test -r /sw/bin/init.sh && . /sw/bin/init.sh export PATH=/usr/local/bin:/usr/local/sbin:/opt/local/bin:/opt/local/sbin:$PATH export DISPLAY=:0
Then, this will change the order of PATH
$ echo $PATH /usr/local/bin:/usr/local/sbin:/opt/local/bin:/opt/local/sbin:/sw/bin:/sw/sbin:/bin:/sbin:/usr/bin:/usr/sbin:/usr/local/mysql/bin:/usr/X11R6/bin
Ok, now I am set. At first, I wasn't sure how to change the order of the PATH since ~/.bash_login was not working and ~/.bash_profile looked a bit weird. It gave me some troubles just like it's said on the page when I skipped this step. So, I suggest you won't fool about this if you're doing this one.
I previousely installed MySQL from MySQL 5.1 Downloads. It is really easy but if you are going for the first time, it's good to read Marc Liyanage - Software - Mac OS X Packages - MySQL as well.
Next thing I was interested in was Mongrel so I needed the latest Ruby. It should go fine as going through the instructions on the page says.
$ curl -O ftp://ftp.gnu.org/gnu/readline/readline-5.2.tar.gz $ tar xzf readline-5.2.tar.gz $ cd readline-5.2 $ ./configure --prefix=/usr/local $ make $ sudo make install
It's just good to have readline.
$ curl -O ftp://ftp.ruby-lang.org/pub/ruby/1.8/ruby-1.8.5.tar.gz $ tar xzf ruby-1.8.5.tar.gz $ cd ruby-1.8.5 $ ./configure --prefix=/usr/local --enable-pthread --with-readline-dir=/usr/local $ make $ sudo make install
Finished smoothly, but before I rush..
$ which ruby /usr/local/bin/ruby $ ruby -v ruby 1.8.5 (2006-08-25) [powerpc-darwin8.8.0]
Just making sure it's pointing at the ruby I just installed.
$ curl -O http://rubyforge.iasi.roedu.net/files/rubygems/rubygems-0.9.0.tgz $ tar xzf rubygems-0.9.0.tgz $ cd rubygems-0.9.0 $ sudo /usr/local/bin/ruby setup.rb $ which gem /usr/local/bin/gem
Yap! it's all looking good! Now, I can play with the beautiful gem tools.
$ gem install rails --include-dependencies $ gem install mysql -- --with-mysql-dir=/usr/local/mysql $ gem install mongrel
And more gem tools are:
$ gem list $ gem dependency rails $ gem cleanup $ gem update --system $ gem uninstall rails
Finally, It' time to setup the rails application.
$ mkdir -p /path/to/application $ rails /path/to/application $ cd /path/to/application $ mongrel_rails start -d
Once mongrel started the HTTP server, I can now access to the rails application from a browser with an address like:
127.0.0.1:3000
I also like the feature that I can easily set the port number with -p option. I suppose I could do the same with script/server but mongrel looks better.
$ mongrel_rails start -p 3001 -d
With this feature, I can launch several rails running on a same machine as development. I am all set now.
References:
Enable Context Menu on Firefox2
Posted by Quinn at November 17th, 2006 4:36pm under web 0 Comments Permalink
Today, I was so happy to find out this. It was so easy to change the configuration for Firefox2.0 to show context menu by a long click. Here is what I did.
about:config
Typing this in the address bar, takes you to configure so much things for your Firefox. But, it's just so many. Then, I put "click" to filter the list of the configurations. Now you will easily find this line.
ui.click_hold_context_menus
It was set to "default: boolean: false" when I first looked at. By double clicking anywhere in this line will change to "user set: boolean: true." This immediately changes the behavior and you are now happy!
According to this page, this feature is only for Mac OS X version of Firefox.
PHP5.2 and class datetime
Posted by Quinn at November 13th, 2006 10:01am under web 2 Comments Permalink
I just found out my own PHP class named "datetime" will stop the whole PHP script with a Fatal Error. This really sucks since most of my stuff includes this. I'm so glad I found out this before upgrading my web server hosting several websites. Phew
PHP5.2 and Drupal
Posted by Quinn at November 7th, 2006 3:21pm under web 0 Comments Permalink
It seems a little chaos over upgrading to PHP5.2, which is released on November 2nd. It looks like PHP scripts which run session_set_save_handler() is affected, and so as Drupal.
session doesn't keep userid with php5.2.0
I'm glad that my web applications are not affected by this since I don't use the function. The solution seems very simple, adding a line in a proper place.
session_write_close();
However, forcing developers to fix things in a situation like this ( PHP5.1.6 to PHP5.2, not a huge jump ) is not really nice things to happen anyway.











