Thursday, January 10, 2008

Installing MySQL driver gem

I have upgraded MySQL from 5.0.27, which I installed about a year ago when I bought MacBook, to 5.0.45 yesterday. The reason is that I learned from a MySQL users group meeting that there are lots of important fixes in the versions above 5.0.30.

In Ruby on Rails 2.0, it is recommended to install MySQL driver gem because the one that comes with Rails is not for production use. The gem command is described in config/database.yml.
i.e. On Mac OS X 10.5 Leopard,
sudo env ARCHFLAGS="-arch i386" gem install mysql -- --with-mysql-config=/usr/local/mysql/bin/mysql_config

Previously, installing MySQL driver gem had failed. I tried it again today now that I have the latest 5.0 version of MySQL. Then the installation was successful.

Monday, January 07, 2008

Ruby on Rails: Symbol#to_proc defined in ActiveSupport

I found it in a blog entry "An Introduction to Ruby's Enumerable Module"

It is interesting and I think I can describe it as very powerful.

Tuesday, January 01, 2008

Ruby on Rails 2.0: link_to for nested resources

If you specify nested resources in routes.rb such as

map.resources :daily_contents do |daily_content|
daily_content.resources :vocabularies
end

you have to specify a parameter for link_to like this:

<% for vocabulary in @daily_content.vocabularies %>
..
<%= link_to 'Show', [@daily_content, vocabulary] %>
<% end %>

The generated URL is like this:

http://localhost:3000/daily_contents/5/vocabularies/2

Moreover, if @daily_content.entities is just an array, which happens to contain an object of type, Vocabulary, the following works as well:

<% for entity in @daily_content.entities %>
..
<%= link_to 'Show', [@daily_content, entity] %>
<% end %>

Again the generated URL is same as above like:

http://localhost:3000/daily_contents/5/vocabularies/2

Wednesday, December 26, 2007

Problem with installing Ruby 1.9 on Mac OS X 10.5 Leopard

I have tried to install Ruby 1.9 from tar ball. But so far, there is a problem and it's not successful.

I borrowed the ideas from the following sites:

"Building Ruby, Rails, Subversion, Mongrel, and MySQL on Mac OS X"

"Ruby on Rails install on 10.5 OS X"

"Trouble with Readline and Building Ruby 1.9"

(Also the same post under ruby-forum: "Trouble with Readline and Building Ruby 1.9")

Still Ruby make is failing with regard to readline.


By the way, I miss Linux package managers. It was easy to see which version of what is installed. MacPort is trying to achieve the same thing. But so far, it was not successful to install it. When it comes to package management, I think Linux is better.

Ruby 1.9 Released

You can download it from Ruby Programming Language site.

Sunday, December 23, 2007

Location of Ruby gems for the preinstalled Ruby on Mac OS X 10.5 Leopard

It's /Library/Ruby/Gems/1.8/gems/

The preinstalled Ruby is /usr/bin/ruby (note: execute "which ruby" from command line), which is a symbolic link to

/System/Library/Frameworks/Ruby.framework/Versions/
Current/usr/bin/ruby


So you would think that the location of the gems is under

/System/Library/Frameworks/Ruby.framework/Versions/
Current/usr/lib/ruby/gems/1.8/gems


just like when you install Ruby manually.
But when I looked at the Rails gem under the directory, it was rails-1.2.3.

I performed a search for "rails" gem under each directory under the path as a root user but all the searches found only the same rails-1.2.3.
So finally I performed a search for the entire directory tree, i.e. executed

find / -name "rails" -print

as a root user. And here it is, it found

/Library/Ruby/Gems/1.8/gems/rails-2.0.1/bin/rails

By the way, as a side note, I wanted to see if "/Library/Ruby/Gems/1.8/gems/rails-2.0.1/bin/rails" is sym-linked from /usr/bin/rails (by executing "ls -alFh /usr/bin/rails"). But it isn't. /usr/bin/rails is not a symbolic link of anything. It's an executable file.

This whole thing is very confusing to me.
All I wanted to do was to look at the Rails 2.0.1 source code.

Thursday, December 20, 2007

Ruby on Rails 2.0 configuration files, etc.

I have read through the files in the Rails project generated with Ruby on Rails 2.0, such as the configuration files, etc. e.g. /config/boot.rb, /config/environment.rb.

I've found that they are more well-written and well-structured.

Ruby gem install error with Mac OS X 10.5 Leopard

I attempted to install ruby-debug gem but it failed with a message:

ERROR: Error installing ruby-debug:
ERROR: Failed to build gem native extension.

/System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/bin/ruby extconf.rb install ruby-debug can't find header files for ruby.


This was because the installed Mac OS X Xcode Tools was old, specifically, GCC was old. I had to install Xcode Tools 3.0, which is actually shipped with Mac OS X 10.5 Leopard DVD. You can also download it.

Thursday, December 13, 2007

Switched to TextMate

As I updated to Ruby on Rails 2.0, I decided to try out TextMate.

After getting used to it after reading its documents, I came to like it because its Ruby and Ruby on Rails Bundles seem to have lots of good features.

But I didn't necessarily like its Subversion Bundle. I had to do "svn import" from the command line, delete the local Rails directory (of course, after backing it up), and check out the directory from the Subversion. Otherwise, there is no .svn folder. With Subversion (Eclipse Subversion Plugin), you don't have to delete the local directory. Maybe there is a better way to make this work in TextMate and I would like to know it.

Sunday, December 09, 2007

Ruby MetaProgramming

Watch the video
"MetaProgramming - Extending Ruby for Fun and Profit"

Isn't this wonderful?

Updating to Ruby on Rails 2.0

Until today, I have been using Ruby I installed manually on /usr/local/ (/usr/local/bin/ruby) because that's how I installed it on Mac OS X 4 Tiger. When I purchased Mac OS X 5 Leopard several days after it was released, I noticed that Ruby was installed under /usr (/usr/bin/ruby) as a part of Mac OS X developer tools. But I kept my .profile with "export PATH=/usr/local/bin:/usr/local/sbin:$PATH" because I had lots of gems installed already under the Ruby under /usr/local (/usr/local/lib/ruby).

Today as a part of updating to Ruby on Rails 2.0, I switched to use the Ruby included with Mac OS X developer tools (under /usr). And updated Rails gem under that location (under /user):

1. Commented out "export PATH=/usr/local/bin:/usr/local/sbin:$PATH" in my .profile. Restarted the shell.

2. Executed "gem update rails".

Ruby on Rails 2.0 Released

See Ruby on Rails official site and Ruby on Rails weblog.

Tuesday, November 27, 2007

Uploading audio file and playing it on a web page using attachment_fu Ruby on Rails plugin

Basically used the information from "File Upload Fu" and "Demonstration of Different Ways to Play a Sound from a Web Page".

Uploaded audio file and stored it in file system just like image file using attachment_fu. Then in show.rhtml,
instead of:

<b>Audio:</b>
<%= link_to @vocabulary.public_filename %>

used:

<b>Audio:</b>
<embed src="<%=@vocabulary.public_filename %>" autostart="false" loop="false" height="20" width="200"></embed>

Of course, if there is a better way, I would like to know.

Monday, November 05, 2007

Ordering a service through a customer support by phone

I ordered satellite TV service by calling customer support by phone because I didn't have Internet access temporarily.
To make the story short, after all the communications, they put a wrong service and now I have to pay for the extra service I never requested for the next 30 days.

I am even more convinced that it's a better approach for a customer to order and select what he/she wants through web site.

Also I am even more a proponent of easy subscribe-unsubscribe model without long-term contract. There shouldn't be any 1-year contract or 2-year contract. The customer should be able to sign up anytime and cancel anytime without any penalty.

It is very unfair that the majority of my money has been lost throughout my life because I was charged for what I didn't ask for and what I was not supposed to be charged for.

I have lived both in a country with excellent customer support services and in countries/regions with customer support personnels doing whatever they feel like based on their emotion. I hope that the more web based approach would make this cultural difference irrelevant.

Saturday, October 27, 2007

OOPSLA 2007 - Thursday

The keynote speech was very good.

In the speech, there was a comment by John Vlissides saying that Patterns were used unexpected way. At that moment, I thought that maybe the reason why he had said to me at one OOPSLA that learning Refactoring to Patterns was better than learning Patterns straight.

One attendee said that "A developer" wanted to work with "A developer" or even a better developer so that he/she could learn from him/her. But "B developer" wanted to hire "C developer" because he/she wanted to work with a developer who was worse than him/her. A, B, C, and D means that A is the best and D is the worst. I agree with him.
And I want to work with a developer better than me and I love to develop a quality software, which means I have to improve my skills even more so that I can have a chance to work with "A developer".

OOPSLA 2007 - Tuesday - 2

50-50 was hilarious. Even just attending this session only would make me feel that it was worth attending this year's OOPSLA.

Thursday, October 25, 2007

OOPSLA 2007 - Wednesday

Many big names from the past made keynote speeches. It was amazing.

Domain Driven Design Movie BOF (Birds of a Feather) was good. It was very clear about how Domain Driven Desisn progresses with developer-customer interaction. I wish they post the movie online.

Tuesday, October 23, 2007

OOPSLA 2007 - Tuesday

The opening Keynote Speech by Peter Turchi was very good. "Get lost" - and experience what you have never experienced before. I agree that's the key of OOPSLA. That's why I come to OOPSLA. And I have lived almost entire life with this joy of getting lost (encountering an unfamiliar thing).

The panel of "Celebrating 40 Years of Language Evolution: Simula 67 to the Present and Beyond" was educational to me. The languages are increasingly getting functional. And multiprocessor hardware is making concurrency the main issue of the coming future.

Monday, October 22, 2007

OOPSLA 2007 - Dynamic Languages Symposium

Quickly, just my impression.

Last year, I got an impression that Dynamic Language camp and Static Language camp would never get along with each other. This year, found that there are some activities to take advantage of the good from both.

As usual, it's good to know and hear about something I have never known before. After all, that's why I come to OOPSLA.

I saw the actual OLPC XO during Dynamic Languages Symposium and Squeak Birds of Feathers session. Also link - XO Giving. It's exciting. I felt like getting one of those and play around with Squeak development environment in Etoy.

There is a Squeak book to download, announced at Squeak Birds of Feathers session.