Working with Ruby

Now that ruby and mysql appear to be working ok, I need to set up a new database. First of all, look at the config/database.yml file. The root user password (or whichever mysql user that you’re going to use) must be put in this file. Then, the database must be created:

yo:~/work/ruby/test1/config maryh$ mysqladmin -u root -p create test1_development
Enter password: 
yo:~/work/ruby/test1/config maryh$ mysql -u root -p
Enter password: 
Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 249 to server version: 5.0.27-standard

Type 'help;' or '\h' for help. Type '\c' to clear the buffer.

mysql> show databases;
| Database           |
| information_schema | 
| mysql              | 
| test               | 
| test1_development  | 
4 rows in set (0.00 sec)

Looks good. Our database has been created.


script/generate migration accounts
vi db/migrate/001_accounts.rb

class Accounts < ActiveRecord::Migration

  def self.up
    create_table :accounts do |table|
      table.column :name, :string
      table.column :budget, :float

  def self.down
    drop_table :accounts

yo:~/work/ruby/test1 maryh$ rake migrate
(in /Users/maryh/work/ruby/test1)
== Accounts: migrating ========================================================
-- create_table(:accounts)
   -> 0.0029s
== Accounts: migrated (0.0030s) ===============================================

The rake task migrate has been deprecated, please use the replacement version db:migrate

So far, so good. I don’t really know what I’m doing, but whatever it is, it’s working.

At this point, I have a database and a schema set up for storing accounts. Now I need to start creating accounts and in rails, this is done with scaffolding.

yo:~/work/ruby/test1 maryh$ script/generate scaffold account expenses

Now restart the server and see how the what I just did, looks.


Ok, things seem to work. I was following through the example here:

Website Design

I need to do some major web design work, so I’m trying to decide how I’m going to tackle the project. I want to use a database and other dynamic stuff, so I was thinking that I’d use php and mysql. But after reading some webpages, I think I’m going to try to learn about Ruby on Rails. It’s more complicated to start off, but should do lots more of the things that I want. So, to get started, I’m loading it on my mac. First step is to load Xcode, then I have to fix the version of ruby that comes with the mac.

I followed the instructions here:

Set up my first project with:

rails /Users/maryh/work/ruby/test1
cd /Users/maryh/work/ruby/test1
ruby script/server

If I then open my browser to localhost:3000, it looks to have worked. Now I need to figure out what I can do with ruby.

At some point, I installed mysql on my mac. I need to change the default password to something.

yo:~/work/ruby/test1 maryh$ /usr/local/mysql/bin/mysqladmin -u root password 'new_password'
yo:~/work/ruby/test1 maryh$ mysql -u root -p
Enter password: 
Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 245 to server version: 5.0.27-standard

Type 'help;' or '\h' for help. Type '\c' to clear the buffer.

mysql> show databases
    -> ;
| Database           |
| information_schema | 
| mysql              | 
| test               | 
3 rows in set (0.00 sec)

mysql> use mysql;
Reading table information for completion of table and column names
You can turn off this feature to get a quicker startup with -A

Database changed
mysql> select Host,User,Password from user where Password='';
| Host            | User | Password |
| | root |          | 
| |      |          | 
| localhost       |      |          | 
3 rows in set (0.00 sec)

mysql> delete from user where Password='';
Query OK, 3 rows affected (0.00 sec)

That gets rid of the accounts that have no password.

Bathroom Has Begun

I finally started working on my bathroom. I’m going to gut the entire room, fix any plumbing issues and then put new stuff in. The putting new stuff in is a little foggy right now because I’m really not sure what I want to do. So, I’m off to the bookstore to get some magazines about remodelling bathrooms, so I have an idea of what I want to do.

Here’s how it looks so far:

I am an idiot

So, after running the migration assistant and copying all of my data, everything was fine except for X11.  Since I use X11 at work on a daily basis, it was very important for me to get this installed.  I decided that I would delete everything I could find from the old X11 stuff and install it new.  Then, I also grabbed the latest updates from Apple.  Reboot and NOTHING.

/etc/master.passwd:  No such file or directory

I’m exceptionally stupid for doing this. And, I didn’t bring the OS install disks to work, so I can’t even fix it.  The only bright side I see to this is that, while it is more of a hassle, I think it’s better to start out with a new installation and copy data than to use the Migration Assistant.  Also, this will be a good learning experience.  I’ll be able to tell all the other Mac users around here what NOT to do.
Still, killing the operating system in less than 24 hours is a new record for me.

New Laptop

My incredibly nice boss bought me a new MacBook Pro, which I just received today. I am now in the process of trying to set my new laptop up just like my old one. I thought I would really look forward to playing with my new toy, but I’m actually dreading it a little. My old PowerBook ran pretty much the same software, so things aren’t really going to be any different. I just have to schlep all my data from the old laptop to the new one. I did use the Apple Migration Assistant to move my programs and things. This worked ok. I still had to go through and delete old versions of things and old programs that I no longer wanted. My iphoto library has come over fine and I’m now waiting for my music library to come over.

Things I Learned

Self-signed certificates, which I use on many sites need to be installed to the Keychain called X509 Anchors. If they just go to Login, you’ll be prompted for them each time.

Iphoto library can just be copied from the old machine to the new one, as long as it’s put in the proper place. On the new machine, that’s in ~/Pictures/iPhoto Library

X11 did not copy over. I’m downloading Xcode to use. I think this will work better than what I had.

I’ve heard lots about Quicksilver and I’ve finally downloaded it and will read the manual to see what makes it so good.

When I get the basics set up, I’ll be getting Parallels and will load windows on this machine.

I need to buy SnapzPro because that will help with creating quicktime movies for help pages