I was not happy when I found myself stuck try to run scaffolding for the first time, discovering that my previous attempt to fix preinstalled Tiger ruby and that after installing Xcode 2.2 I don’t have ruby.h where fixrubyconfig expects (as per the most famous fix Complete Fix for Ruby on Mac OS X 10.4 Tiger which is also mentioned in Agile Web Development with Rails
I was partly heart broken and partly frustrated and hoped that some mac and ruby ‘guru’ at the upcoming Seattle.rb Hack Night can help.
But then I had a thought and it worked.
I installed the latest stable version of ruby (1.8.3):
Download from: ftp://ftp.ruby-lang.org/pub/ruby/ruby-1.8.3.tar.gz
shell> tar -zxvf ruby-1.8.3.tar.gz
shell> cd ruby-1.8.3
shell> make -j5
shell> sudo make install
This installs the new version of ruby in the /usr/local/bin directory on your powerbook
Now I added the new ruby path to my $PATH using
this would mean that any time a issue a command it would look in /usr/local/bin before /usr/bin where the old (tiger default version is installed). I have also modified my .profile to have a similar PATH in future.
then I downloaded and installed rubygem again:
Download from: http://rubyforge.org/frs/download.php/5207/rubygems-0.8.11.tgz
shell> tar -zxvf rubygems-0.8.11.tgz
shell> cd rubygems-0.8.11
shell> sudo ruby setup.rb
Next I installed rails gem
shell> sudo gem install rails --include-dependencies
Next I installed mysql gem
shell> sudo gem install mysql -- --with-mysql-dir=/usr/local/mysql/
it worked for the first time now giving me a successfully installed message.
Finally I was able to do my scaffolding task as suggested by the book:
from your rails app directory do the following for the existing product table
shell> ruby script/generate scaffold Product Admin
It seems that the on Mac OS X you require a username in your database.yml file (you can’t leave it blank otherwise it would default to root) so I had to modify my configuration on last time before seeing the magical command work.