Ruby

Dreamweaver 8 as a Ruby IDE

In last week's post, I talked about how I was trying to find a suitable IDE for Ruby on Rails development, and how my preferred solution would be a syntax highlighting plug-in or modification for Dreamweaver or Visual Studio.

I also provided a link to this tutorial from BDC Software, which implied that with a bit of tweaking, Dreamweaver could not only do the syntax highlighting, but even code hints too. I tried it, and it worked, so the rest of this post is a step by step process for both, which borrows an awful lot from that tutorial, and from this page from RubyGarden.

A Little More on Rails

Last week I started talking about giving Ruby on Rails a try, and I had planned to have plenty more to say for this post. I have a printed copy of the great looking Four Days on Rails guide sitting on my desk, and I’ve been looking forward to digging in.

Unfortunately, aside from a minor quest to figure out how to customize IDE syntax highlighting, the experiment took a bit of a backseat this week. So, I’m going to go back to what I learned the previous week and share something from the starter tutorials that really got me excited about working with the framework.

Business Logic != Database Logic

Databases are good for one thing: storing data. But so are spreadsheets, PDF files, and the like. What separates out a good database from other data storage facilities is the ability to retrieve and store records in the database efficiently.

There are a lot of table models that seem to be more worthy of a spreadsheet than a database. For example, consider this scaled down employees table (my apologies for the dots, but it makes the formatting work):

+----+------+------------+
| id | name | department |
+----+------+------------+
| 1. | Bob. | Sales..... |
| 2. | Mark | Shipping.. |
+----+------+------------+

Riding the Rails

The first couple of times I didn’t really know what they were talking about, I’d seen the name before, but usually just as the title of a forum or blog post that I didn’t bother to read. Once I realized that they were talking about a web development framework, I felt like I knew where the loop was, but still couldn’t understand why so many people had so much to say about it.

I’m talking, of course, about Ruby on Rails, and all the extra work my tired desktop developer’s brain had to do to filter out all the Rails evangelism. Well, the time came; I had enough free time to give it a try, and I wanted to know what all the fuss was about.

Ajax Toolkits, Widgets and Rails

Originally I planned for this post to be a sort of how to for creating floating content panes in a Rails application. If you’re unsure what I’m talking about have a look at protopage or Winlike for decent examples. I didn’t want to write everything from scratch so I began a search for reusable code in the form of a widget that I could use that would make sense for the example. What I found was that there’s a lot out there and there are different approaches to web based widgets. What follows are a few of the things I found and an open question on what the best approach may be.

Quack Quack

One of the popular aspects of Ruby is the concept of "Duck Typing". It's a powerful aspect of the language that, once understood and utilized, shows the uniqueness of the Ruby type system.

One example I like to use when demonstrating what duck typing is to demonstrate this pseudo Ruby-code:

int someFunction(blah)
{
  if(blah.class == String) return blah.to_i
  elsif(blah.class == CustomClass) return blah.convert_custom_class_to_int
  elsif(blah.class == AnotherClass) raise "Can't convert AnotherClass to int!"
}

The above code shows a (poor) implementation of trying to do certain actions based on the class of the object. But why? What happens if we create new custom classes - then we have to go back and update this function to handle them. What we create a new String based class that has all sorts of new funky features. This doesn't fit into this model very well, either. Why not just do this:

Data Types - PHP Vs Ruby (Part 2)

Ruby's types are actually objects with methods, which is different than PHP's primitive types. At first, I thought I'll have to do something like

age = Number.new(28)

Not so, in fact the number classes don't even have a new method. Declaring a value to be a number is:

age = 28;

I'm sure there's some fancy word to describe the magic that happens. I like automagically.

Using UUID/GUID as Primary Key in Rails

A project I'm working on has a difficult requirement to meet. It needs to be able to support a multi-master database model. If you're already familiar with the concept, please forgive the following short introduction. This means that multiple systems need to be able to create records in their local database and sync up to other ones later. Connection among the systems is not guaranteed to be up 100% of the time. A prime example of this type of system is Microsoft's Active Directory.

Poking around in Ruby

Ruby for Windows (I'm not sure if other operating systems have similar, but I would think so) has a program called "fxri - Interactive Ruby Console and Help." This little application consists of a frameset with one panel as a documentation browser, one panel to display the help for the currently selected item and an interactive console. This can be a great aid in learning ruby and for testing out functions or code. Here I'll talk about a few things I've learned with this.

You get a prompt as you would with an operating system, looks something like this:
irb(main):001:0>

Interview with QtRuby Author Caleb Tennis

In case any of our readers are interested in hearing a bit about the man himself, an interview with our very own Caleb Tennis is available on the website of Andy Hunt of the Pragmatic Programmers'.

Check it out and enjoy.