posts by tag

development (44)
Golf Trac screen shots

Unfortunately, it has been a while since I’ve worked on Golf Trac. The end of grad school got a little crazy, and with the holidays and everything, it has been on the back-burner (I hope to have it finished by spring, though).

I’ve been keeping track of the progress by posting screen shots on Flickr, but always kept the images private. I for one enjoy looking at designs “in the making”, so I feel somewhat obligated to share. Prepare yourself… I’m unveiling to the world: Golf Trac screen shots! It’s pretty basic, but I think that’s a good thing. If nothing else, you can at least get a feel for the interface. Enjoy.

Rails tip: handling a random sidebar

As you may or may not know, I’m working on a new portfolio. And while designing out the pages, I realized that there are times when I want a sidebar and times when I don’t. “Oh, I know, I know! content_for, right?” Yes and no.

content_for is a drop-in solution when content is always there, but changes dynamically depending on the template. It can’t really be responsible for structural changes, but rather the content represented within a structure (read: content within the sidebar, not the sidebar itself). Yes, I know I can use content_for to show/hide the sidebar as a whole, but what about the case when it’s not present? There’d be an empty sidebar area that my content may want to take advantage of, which is where my problem lies.

I didn’t want a javascript solution to stretch out the content if no sidebar exists (no matter how unobtrusive); I wanted it to be rendered as intended for that view. See the problem? The sidebar does change depending on the template (content_for), but I also need to handle the case where I don’t want the sidebar at all by stretching my content out to the distance of the space the sidebar would have taken up. Leave it up to me to make an easy concept confusing.

So, now that I’ve detailed the problem, let me just say that I’m completely aware that this isn’t the only way to do this. I’m not saying this is the best way, either. But so far it’s working well for me.

I approached the problem thinking of two “mini-layout” situations, where it really boiled down to a couple of CSS classes for the content and a “to be or not to be” sidebar. My two CSS classes: ‘medium’ and ‘large’. As one might deduce, the ‘medium’ content would be the view with the sidebar, and the ‘large’ content would extend the full width with no sidebar. Here’s a template that would contain a sidebar:

<% content :medium do -%>
  <!-- markup for the standard content area -->
<% end -%>

<% sidebar do -%>
  <!-- markup/partial for the sidebar -->
<% end -%>

Pretty straight forward, huh? Just to be complete, here’s a template that would not have a sidebar where the content would eat up that extra “wasted” space:

<% content :large do -%>
  <!-- markup for the expanded content area -->
<% end -%>

Again, this may or may not be the best way, but here’s the snippet from the layout:

<%= content_tag :div, :class => @size do -%>
  <%= yield -%>
<% end -%>

<%= yield :sidebar -%>

Pretty simple. Here are the content and sidebar helpers:

def content(size, &block)
  @size = size.to_s and yield
end

def sidebar(&block)
  content_for(:sidebar, content_tag(:div, capture(&block), :id => 'sidebar'))
end

Now, if I could only solve the problem that is wanting to build too many applications at once, I’d be set.

Tabbed navigation tip for Rails

UPDATE see the refactored version here

A very common pattern in a lot of web applications is a tabbed menu with the current tab highlighted. Last night I spent some time refactoring the navigation in Golf Trac, and I thought I would post what I did, just in case someone is new to this and goes overkill on the implementation.

First of all, Rails in its entirety thrives off of conventions. It’s inspirational to say the least. I’ve embraced a conventional way of thinking in my tabbed menu implementation, so let’s get down to business.

Tabbed navigation for actions only

For this example, I’ll use a public_controller, which contains a few actions that aren’t restricted behind a login. Just to get you excited, here’s what the end result will be:

navigation ['login','register','about','tour']

You might immediately think that each link passed in is the title of an action and the route is generated by appending _path on the end. Actually, that’s pretty close. The problem I had with that quick-and-dirty implementation was the ambiguity of the named routes. For example, in Golf Trac a user can create a New course and a New round. Well, that means I have two “new” things. I couldn’t generate a named route such as new_path because it’s ambiguous.

To alleviate this problem, I’m using controller.controller_name to make the routes unique. I’ll just give the implementation (I made a pastie, as well) and mention a thing or two about it afterward.

def navigation(links)
  returning html = "<ul>" do
    links.each do |link|
      html << "<li class='#{css_for(link)}'>#{build_link_for(link)}</li>"
    end
    html << "</ul>"
  end
end

You could use content_tag instead of explicitly writing out the <ul> and <li> stuff, but sometimes I find this easier on the eyes. The css_for(link) method just pulls out a lengthy if condition (better readability) to determine if it’s the selected tab, but for completeness, here are the details:

def css_for(link)
  controller.action_name.downcase == link.downcase ? 'current' : 'plain'
end

The build_link_for(link) method simply generates the link with the appropriate named route dynamically, but again, here are the details:

def build_link_for(link)
  link_to link.capitalize, send("#{link.downcase}_#{controller.controller_name.downcase}_path")
end

Now, that’s how to select the current tab for a list of actions within a controller, but what if you wanted to select the current controller, too (i.e. nested tabs)? It’s simple. All you have to do is check if the controller.controller_name.downcase instead.

Modified for controllers and actions

In Golf Trac, I have a sidebar which has a menu that highlights the current controller, then in the corresponding content area, a set of tabs for each major action within that controller, which also get highlighted upon selection. So my navigation helper is more complex, but not by much:

def navigation(links, from_layout = false)
  returning html = "<ul>" do
    links.each do |link|
      html << "<li class='#{css_for(link, from_layout)}'>#{build_link_for(link, from_layout)}</li>"
    end
    html << "</ul>"
  end
end

Also, you’d have to modify the css_for(link) method to accept the from_layout parameter so it would know if it was supposed to check the controller or action name. Here’s how I’m currently doing that:

def css_for(link, from_layout)
  controller.send("#{from_layout ? 'controller_name' : 'action_name'}").downcase == link.downcase ? 'current' : 'plain'
end

It’s basically the same thing, only I’m determining if I need controller_name or action_name based on the from_layout parameter. And the build_link_for(link) method needs updated, too:

def build_link_for(link, from_layout)
  controller_path, action_path = "#{link.downcase}_path", "#{link.downcase}_#{controller.controller_name.downcase}_path"
  link_to link.capitalize, send("#{from_layout ? controller_path : action_path}")
end

It’s the same deal here. If it’s an action, then I need the route that has the controller name appended to it. The nice thing is the more frequent situation (view templates) would not require a true or false parameter (since it’s defaulted to false), so it keeps the API nice and clean. And you’d only have to add it in your layout once, like so:

# views/layouts/[whatever].rhtml
navigation ['login','register','about','tour'], true

Here are the routes that would work with the above example:

# config/routes.rb
map.with_options :controller => 'public' do |path|
  path.login_public '/login',       :action => 'login'
  path.register_public '/register', :action => 'register'
  path.about_public '/about',       :action => 'about'
  path.tour_public '/tour',         :action => 'tour'
end

TODO: determine a way to not require an extra parameter (from_layout), but have the helper know where it’s being called from and act accordingly.

Conclusion

Currently, I’m using this implementation to navigate around five controllers (in the sidebar) and 13 or so total actions (in the content areas). I personally like passing the text that I want to display as tabs, but that’s just one of the hundred ways to dynamically construct a tabbed menu in Rails. Whether or not you do something like I’ve shown above, I strongly recommend you setup some sort of convention to base it on. Be smart about the design and you can get so many things for free.

Golf Trac was flagged tonight

Literally. The past couple of nights I’ve had some time to work on Golf Trac. I spent most of the time coding, but I did stop to visit a few spots that were begging for attention. One of these spots was the dull header image. I shrunk the green a bit and added a flag. It doesn’t have anything to do with “tracking” a golf game, but I believe it was a needed adjustment. I did consider something corny, like making the flag stick the “L” in GOLF, but it just didn’t look right. Maybe that’s because I can’t make a nice flag stick in Photoshop. At any rate, here’s what I came up with…

Golf Trac will support OpenID

The other night, I added OpenID support for Golf Trac. I’ve been using it (OpenID) more and more lately and I’m starting to really like it. It’s so easy. Since not everyone uses it (yet), I’ve implemented username/password registration, as well. Going from username/password to OpenID, or vice versa, is no problem. The accounts can be easily merged as long as the email that is registered is the same email associated with the OpenID account.

Technically speaking, managing both login types for the same account didn’t go quite as smoothly as planned. I didn’t want to create a second username/password registration process just because a user had an OpenID, so it was somewhat involved to come up with a work-around. I had a few issues bypassing certain validations, but all is well now. And besides, it’s only a little awkward in the rare case (going from OpenID to username/password). The typical case (going from username/password to OpenID) is completely seamless. If a user already has a username/password, signing in with OpenID will then tell Golf Trac to merge with the existing account.

If you think managing multiple logins is a pain, you really should look into OpenID.

Warehouse: web-based SVN browser (and other)

A couple of days ago, Active Reload released a web-based SVN browser that doesn’t suck: Warehouse. I’ve gone as far as browse around the demo, look at screen shots, videos, tutorials, etc. I have to say, from what I’ve seen so far, I’m impressed. I just might be willing to pay the $30.

And while I’m at it, Lighthouse looks like a great bug tracking tool, as well. It integrates with subversion, too (maybe via Warehouse ?) Currently, I’m the only one working on Ruby/Rails stuff at work, so my bug tracking system usually remains in my head (or at best, ends up on scrap paper somewhere).

One more thing, Versions is what seems to be a “tortoise for Mac” when dealing with subversion. I, personally, prefer to use the command line over tortoise, but usually things built for the Mac look and feel a lot cleaner than the Windows counterpart. But that also applies to command line, in which I don’t see how I could pass up that terminal.

Code abstraction and Rails

Sometimes I have a hard time abstracting code when developing in Rails. I mean, the act of abstraction itself isn’t the problem, it’s how far to go with it—or more accurately, when to stop.

When I first started doing web development, I wasn’t too concerned with abstraction. I barely even knew what it was. Like most beginners, if I got something to work, I was satisfied… until I wanted to update something. It was an obvious pain to modify and update code, since I had to remember (or search) for all instances to stay consistent. Then (in addition to object-orientation), I realized that anything I was duplicating I should extract out so I could reuse it—brilliant! (It’s weird to think I was at a point where I didn’t think like that.) So I began to abstract only to prevent duplication. Now, with Rails, I can’t help but abstract everything. Ruby is so readable by nature, it’s stupidly tempting to want to continue that.

I enjoy immediately knowing what’s going on in any of my methods, just by reading them. Typically, I set them up that way. Sometimes, though, it seems like I’m tracing through all of these abstracted methods, and I don’t know if that’s a good thing. As an example, here’s a method I wrote to publish content out to XML:

def publish_xml_for(root_id)
  content = Content.find(root_id)
  create_publish_directory_for(content)
  output_xml_for(content)
  flag_as_published(content)
end

Anyone can look at that and know what’s going on. I’m not necessarily reusing any of those methods (yet, anyway), I just like how readable it is. But altogether, the publish_xml_for method works as a compilation of 5 or 6 methods (the methods inside of it are also abstracted to be very readable—it never ends).

Also, I find myself writing private methods within the controller class—would it be better to add these to some sort of extension in the lib directory? I don’t do that very often, so I have yet to build up habits as to when that should happen. I’ve written some tag extensions for polymorphic tagging, but that’s about it.

ASP on Rails

I’ve been developing solely in Rails for several months now (a lot longer considering my own time), and I’ve become biased as to how web applications should be setup. And how’s that you ask? Exactly like Rails. If you’re subscribed to my web portfolio feed, you’ve probably already seen the most recent project I just added. You may also already know that it was built in ASP/VBScript.

Before Rails, the only other web development experience I have is in PHP and a little bit of C#/VB .NET crapola. So I don’t know a whole lot. The PMI project was to be built in regular ASP and VBScript, which was completely new to me. From the beginning, I knew I wanted to try and adopt some ideas brought forth by the Rails framework. I quickly realized how spoiled I’ve become (it took way too long just to get the DB and configuration stuff working). Trying to set my own conventions, I was able to do things like generate menus and sub-menus dynamically based on page location. Here are a few other things I tried in order to mimic a Rails environment:

  • included a separate helpers file that had various methods to ease my pain (which is better: response.write("message") or p("message")?)
  • mocked model classes by building CRUD operations in classes based on the DB table names
  • used one “layout” file that contained the header, footer, sidebar, menus, etc, while loading dynamic templates based on location (I have a gripe about how I had to do this, though)
  • convention over configuration

More about the gripe with my generic dynamic templates. This is where I was limited the most, as ASP doesn’t support dynamic includes! Instead of using a convention to fill in the file I needed based on page location (i.e. <!--#include virtual="/content/<%= get_page_name %>.asp"-->), I had to have a “content_for_layout” file that had about 20+ if/elseif conditions to determine which content to load. And it gets much worse. Even though only one of those includes are executed (the one inside the true if condition), all of them get loaded. I only needed one view at a time, but had to basically load every template within the site. Awful.

In the end it was kind of fun breaking away from Rails for a little while. Well, it wasn’t fun leaving Rails, it was fun learning something new, though. And on a side note, I can’t fathom how brilliant and consistent you have to be to extract out a framework such as Rails. It’s amazing. I’ll probably be releasing ASP on Rails under the GPLv3 license in the near future, so stay tuned (haha… not really).

A few useful programming resources

As a web developer, I spend some time looking up better syntax or methods to achieve the most efficient solution. I thought I’d make note of some of the resources I use almost daily. I’m primarily developing in Ruby/Rails right now, but some of these resources are outside of that. Here they are, in the order I tend to use them…

  1. Rails API—It’s nice if I know exactly what I need.
  2. Got API—I think we’ve all used this a time or two, or at least are aware of it. I find myself using http://start.gotapi.com more than http://gotapi.com itself. They’re both extremely fast ajaxified interfaces.
  3. Pickaxe online—I prefer the hard copy over the online version, but I do use it occasionally.
  4. Rails API search—This is good if you’re seeking examples (although, not all methods come shipped with examples).
  5. Ruby on Rails Forum—I use this more for posting questions, although I haven’t done that in a while. It’s probably not bad to search for solutions, though.

I thought I had bookmarks of sites that allow you to paste snippets of focused code, but I can’t seem to find them, nor remember what they are. They show their face occasionally on Google searches. If you know of any other “must-be-aware-of” references, leave them in the comments.

Another drab part of web development

Last week I read that Flickr has 525 million photos now (which is nuts) and 55% of Flickr users reside in non-US countries. That means ~289 million photos come from outside of the US. And that’s before they added any multi-lingual support just last week, which amazes me (I could never use an application that’s in another language, even if it’s image-based).

I’ve already mentioned what I think is the worst part of web development, but I’ve since thought of another candidate: internationalization and/or localization (I think they’re the same thing). The reason I can’t explicitly say this is ahead of or just under deployment is because I’ve never actually done it. I know there are plugins (for Rails, anyway) that assist in this issue, but even so. Easy or hard, I’m glad I don’t have to worry about it. I just think it’s a boring problem.

The worst part of web development

I started a post on this a couple of days ago, but haven’t had a chance to finish it. After reading Chris’ Deployment woes on the slate blog, I figured I’d go ahead and post a few of my thoughts on deployment.

I’ve spent the last couple of years working in web development and I’ve loved (nearly) every bit of it. But there is a part of this field that I don’t like very much: moving an application into production. Typically, I end up in one of these three scenarios:

  1. successful deployment on the first attempt—in fantasy land, maybe
  2. unsuccessful deployment and knowing what the problem is—this is usually where I end up, where I’ve forgotten to do something, or incompatible versions exist, or whatever
  3. unsuccessful deployment and not knowing what the problem is—this is what I fear and despise, and is the very reason for my pessimistic outlook on deployment

In the first case, life isn’t too bad. Still, whether it’s 10 seconds or 10 minutes, it’s always stressful waiting to see if the application is still alive after deployment. What a relief when everything goes smoothly.

In the second case, it’s somewhat comforting to have an immediate idea as to what the problem might be; but at that point I’m working in light speed trying to fix whatever is wrong. Annoyingly, I always make quick decisions which usually have consequences. But nonetheless, this case is just a matter of time until you crank through the things you’ve realized were wrong.

The third case is flat out sickening. I love problem solving, but that’s different. I get chills just thinking about number three. I’ve been in that situation more than I’d like, even with my own site. That type of troubleshooting is terrible. As soon as I resort to Google, I’m in a state of desperation. And of course, a lot of what works for other people never seems to work for me.

The other day I had about 2 hours worth of troubleshooting a live application after deploying (it could have been worse, I guess). Looking back, I don’t know why it took me that long to fix. Maybe it relates to how disoriented and frantic I get when trying to fix something in production. Unfortunately for me, I’ve yet to come up with a consistently smooth method of deployment. Capistrano looks ideal, but when I tried it the second time a few months ago, I couldn’t get everything working properly, so quit on it. The bottom line: deployment is by far the worst part of web development.

SCM browser coming soon

This subversion browser looks promising. I don’t know how to compare it to other SCM browsers, since I’ve yet to use one, but it looks quite useful. I think Trac integrates with subversion, but again, I’ve never used it.

Site updates and new additions

I recently got a little ambitious and decided to make a few changes. The most obvious is probably the post headings. I thought they blended too well with the rest of the site, and felt they should stand out a little more. So I did just that. I’ve also eliminated the 100% stretch of the post header and comment form. I don’t know why I did that, though. A matter of personal preference I suppose.

The new additions concern the portfolio section. It’s far from anything professional. It’s a quick-and-dirty approach, but I like having a space to collect a few of the sites I’ve built. That’s nothing new, but this time I’m using attachment_fu to load multiple screen shots per project. attachment_fu is awesome if you didn’t already know.

Something brand new is the photography section of the portfolio. There’s definitely nothing tricky there, I’m just pulling in some favorites from flickr (that I took, of course). I love looking at photos, even if they’re my own photos :-)

Oh, and I’m using lightbox v2 to display the screen shots and photos in the portfolio. The mootools version is slightly faster, but Rails already integrates with prototype and scriptaculous very well, so that was the route I took. As far as I know, everything looks good (and works) in all browsers (I haven’t made it to a Mac, however, but I don’t suspect any complications there).

Another image gallery

I’ve been slowly working on the portfolio section of this site, which always leads me to browsing galleries (hence the slowly part). They’re a dime-a-dozen these days, but I thought this one was cool enough to mention. It’s based on the moo tools JavaScript framework I believe. It’s still a little too shaky for me to actually use, I just thought it was compact and easy. I’ll probably just go with some flavor of lightbox, though.

sql query: development versus production

Have you ever heard of a SQL query running fine in development, but returning an empty set in production? Usually that links to being an inconsistent data problem, but it’s the same data in this case—I’m confident that’s not it. I’m sure my local version of MySQL is newer than what’s in production, but that can’t be it, can it? Is that even something worth thinking about?

What an annoying turn of events. I don’t even know where to begin on this one.

UPDATE: fixed. From now on, any problem I have, no matter how small, I’m going to post it. Seems to be the fastest way to realize a solution.

Unexpected trouble with a sql query

I’ve done this before. I know I have. The concept isn’t difficult at all, but this query is giving me a headache. Before I change the way I’m doing this, I thought I’d post about it since that often helps me to think things through, overcoming the obvious.

So a user can take assessments on individual topics/sections of a course, which can then be used to make up a course grade (if desired). Anyway, it was decided recently, instead of updating a users score when a topic assessment is retaken, save all scores so they can see their progress. There are plenty of ways to do this, I realize, but I thought it may be easiest to insert a new record for that user/topic combination and just pull out the most recent (as this isn’t something you “rollback” to—at most, you’d just want to see previous scores, etc).

That brings me to this query. I need to get all of the topics for a course, group them (since there are now multiples), and only return the most recent of the group. Pretty simple, eh? I tend to agree. However, whether it be that I haven’t written explicit SQL in a while or I’m completely overlooking the obvious, I’m not getting what I need. I can get the record individually from the group, without the other topics; or I can get all the topics except the most recent of the group. So I thought about UNION, but that seems over-the-top for this. It’s hard to accept a monster query when I don’t think it should be monstrous. Here’s a dumbed down version of the setup:

## TABLE: courses (has_many topics)
 #   id, title, description, etc
## TABLE: topics (belongs_to course)
 #   id, course_id, title, description, etc
## TABLE: user_topics
 #   id, user_id, topic_id, score, completed_on, etc
 # ----------------------------------------------------
 # (note: topics can be infinitely nested with itself as 
 #  well, but that relationship shouldn't matter, here)

## SQL (1)
 # => returns everything except the most recent topic -
 #    in fact, it doesn't return any records within that 
 #    "group" of topics

 select topic_id, score, completed_on
 from user_topics ut
 inner join topics t on t.id = ut.topic_id
 where t.course_id = {course_id}
 group by ut.topic_id
 having ut.completed_on = max(ut.completed_on);

## SQL (2)
 # => same results as above

 select ut.topic_id, ut.score, ut.completed_on
 from (select topic_id, score, max(completed_on) as max_completed_on
       from user_topics
       group by topic_id) ut
 inner join user_topics u_t on u_t.topic_id = u_t.topic_id
 inner join topics t on t.id = ut.topic_id
 where t.course_id = {course_id} and ut.completed_on = max_completed_on;

Anyway, there are several other attempts, but no reason to list them. I don’t expect anyone to think about it, I was just hoping to clear my mind and give it another shot before handling this a different way. I suppose I could treat it as a “version” of a user_topic, but my stubborn side won’t let me move past this; the data is there, I just need to get it out. I remember when I used to LOVE writing SQL—I’m afraid those days are long gone.

Trouble sorting a hash (sort of)

Last night I removed my custom tagging system, and converted to acts_as_taggable. I’m thinking DHH’s code is probably a little bit better than mine (just a hunch). I’m also converting my tag methods to use some of the other nice things acts_as_taggable provides, such as: find_tagged_with, tag_names, and one of the reasons for this post, tags_count.

The tags to the left are now being pulled via the tags_count method, but I run into a problem. That method returns a hash where the key is the tag name, and the value is the post count (i.e. [[“rails”, 38],[“personal”, 37], ...]). That’s great and all, but I need to sort it in descending order, based on the value and not the key. So here’s what I’m doing:

def self.get_popular(options={})
  Post.tags_count(:limit => (options[:limit].to_i || 10)).invert.sort.reverse
end

The #invert method of the Hash class essentially swaps the key => value pairs to become value => key pairs. This allows me to call #sort which will then sort by the value (aka the count) rather than the key (aka the name). And at the end of this chain we have #reverse which just gives me the descending order. Seems to work, right? Well, almost.

The problem I’m having is when two tags have the same post count. It seems to then grab only one of them (the first in the alphabet?) I don’t exactly know if this is something I’m worried about fixing, but it makes me feel as though I’m not in control of the code, which I don’t necessarily like. Plus, I don’t know that I fully understand what’s happening, here. It’s ignoring the redundant values in the sort. Thoughts/ideas are welcome, even if it means a new method to get the posts-per-tag count.

Yet another redesign for rpheath.com

And here’s the real reason why I have a site (read: so I can rebuild it over and over). I’ve stripped it down to the bare essentials, and found better ways to implement what was left.

This is my first 3-column layout, although it doesn’t really feel like a 3-column layout to me. And maybe that’s a good thing. Point being, I wanted something different from previous versions, and quit making it more than it had to be. I’ve yet to supply a list of full entries up front. But it was long overdue. I’m actually satisfied with the code this time, and I refused to cut corners. Now, I feel as though it’s worth the effort to make changes and enhance what’s here.

thanks to chris scharf

For a few things, actually.

  1. Idea for a no admin interface (although I’m not using the authentication key, I did manage to get rid of the entire admin section).
  2. Idea to list posts not based on a limit, but on a period of time. However, if I go on another posting drought, rather than letting the site go blank, I’m using the month number as the limit of recent entries (so April would be four entries, May would be five entries, and so on).
  3. And finally, the eztime plugin. I’ve been dragging my feet on using this, and although I’m not overwhelmed with time formats here, I can see its power. Playing a bit in the console has shown me how intuitive it is—great choice of keywords.

keep an eye out

I’m not claiming that there are no bugs, so if you notice one, please let me know. Like I said before, I’ve tested it in [mac] Firefox, Flock, Safari, [windows] Firefox, Flock, IE7, IE6 (I hate the has layout problem). I’ve also mapped the old RSS feeds to the new methods, so you shouldn’t have to update your feeds—let me know if it’s not working. And that’s about it. I might post a follow-up on more details, but we’ll see how it goes.

CSS, IE, and conditional comments

I’ll start off by saying I despise Internet Explorer—all versions. I mentioned my desire for a fresh site, and so over the last couple of days (mainly the weekend) that’s what I’ve working on. I only have a few more hours left, mostly on admin-ish type features (as of now, I have no way to post, edit, delete anything). I’ll save the details for the “grand opening” post.

But I do want to express my frustrations with building the layout. First, CSS is amazing; second, IE is not. I know I could ignore IE, since hardly anybody I know uses it, but it’s tough for me to accept my site not working in certain browsers. It’s an unfortunate disease.

I’ve decided on a 3-column layout (my first ever). I wanted the side columns at a static width, while the center column (the content) was liquefied. Despite what you may think, that’s not the easiest cross-browser layout to achieve—for me, anyway. So I decided on 1 of the 10,000 ways this could be done. Everything was going as I expected it to (in Firefox). Those expectations also included the layout not working in IE6. And of course, it didn’t.

So I started writing some * html hacks, and got everything aligned to match Firefox. I finished it up, pulled in some real data, and everything looked good. I was satisfied. Then I thought, “well, I had better check IE7,” just to be sure. Lo and behold, the left column was missing entirely. I was livid. Here we go again.

I stripped out all of the * html crap and made separate CSS files: a default, one for IE6 hacks, and now, one for IE7 hacks. So currently, I’m using conditional comments to load separate style sheets. What an ugly pain. The thing that bothered me the most is how IE6 was closer to being correct than IE7. For IE6, I really only had to adjust the left hand column width a bit (and a few other things, of course), but at least I could see the column. For IE7, I had to entirely change the positioning. Once I found it and brought it back, it wouldn’t re-adjust with the fluidness of the center column; it would either gap or overlay it, which was hideous.

Based on what I know about CSS, Firefox did exactly what I expected. Both IE’s did not. Granted, my CSS may not have been ideal or I should have done it a different way, IE has done nothing in the past that would let me believe it was my fault. I expected more out of IE7, not less.

In closing, here’s the status. I’ve approved the layout in the following environments:

  • Windows: Firefox, Flock, IE6, IE7
  • Mac: Safari, Firefox, Flock

And all is well, finally. I didn’t bother with IE on a Mac, because I figured anyone with a Mac is NOT using IE. And if they are, they’re not interested in my site :-) And now I have class tonight and tomorrow night, so that will more than likely delay progress for two more days. Blah. I’ll keep you posted.

Rails tips and tricks, part 3

One thing I really hate about Windows development is no terminal. I love the command-line, and while there exists one or two substitutes, it’s still a far cry from the real terminal. The Mac terminal. Despite my bitterness, most, if not all, of these tips concern the command-line.

Subversion integration

When I first started using subversion, rather than jumping right in with tortoise, it was recommended that I become familiar with the svn commands. Since I’m somewhat partial to the command-line, that’s what I did. In fact, that’s all I do.

One thing that quickly annoyed me was having to do an svn add whenever I generated something (model, controller, migration, etc.) That’s when I found use in tortoise, to easily view all non-versioned files. Then I learned that you can pass the --svn option onto the end of any “generator” to automatically do an svn add on those new files. Oh, and it works for script/destroy, too. Sweet.

## will also add files to subversion
$ ruby script/generate model Project --svn

## will also remove files from subversion
$ ruby script/destroy model Project --svn

## FILES AFFECTED:
 #   1) project.rb             - the model itself (in app/models)
 #   2) project_test.rb        - unit test (in test/unit)
 #   3) projects.yml           - project fixture (in test/fixtures) 
 #   4) XXX_create_projects.rb - migration (in db/migrate)

It works with all generators, including your own.

Console: interactive application

The console is a good place to quickly interact with your application. In fact, did you know your entire application is actually tucked away in an object, waiting to be woken up from the console? Here’s some of the things you can do:

$ ruby script/console
>> app.url_for :controller => :public, :action => :about
=> "http://example.com/public/about"

>> app.get("/public")
=> 200
>> app.get("/ryan")
=> 404

# others include
>> app.response.headers
>> app.response.body[0,75]
>> app.post("/collection/add/1")
>> app.response.redirected_to
>> app.follow_redirect!

# fix errors in your code, then...
>> reload!

Pretty straight-forward.

Console: setting a default object

If you’re going to be interfacing with your “app” object a lot (or any object for that matter), it may be worth it to set it as the default.

>> irb app
>> get "/public"
=> 200
>> get "/ryan"
=> 404
>> exit

# now you're back to normal
>> 

Console: routing

Routing can get tricky, and sometimes you need to stop and quickly double check that it’s all working properly. Well, by setting the default object to the Routes class, you can quickly analyze your routes.

>> irb ActionController::Routing::Routes
>> puts routes
ANY  /                                    {:action=>"index", :controller=>"public"}
...
ANY  /:controller/:action/:id.:format/    {}

# independently play with paths
>> recognize_path "/about"
=> {:controller=>"public", :action=>"about"}
>> recognize_path "/public"
=> {:controller=>"public", :action=>"index"}

# or check a path inversely
>> generate :controller => "public", :action => "about"
=> "/about"
>> generate :controller => "public", :action => "index"
=> "/"

And on and on. The console is awesome, really, and I don’t use it near as much as I should. I just wish I had that Mac terminal.

Navigation helper acting weird

The I’ve handled tabs in the past has always bothered me. I’m trying to handle them a different way, now that I have better options. Just like anything you do the first time, I’m sure this could be improved upon—but here’s what I have:

# application_helper.rb
def main_navigation(links)
  li_class, link_class = 'left', 'non-current'
  nav_bar = Array.new
  links.each do |link|
    li_class = 'right' if controller.controller_name.downcase == 'settings'
    link_class = 'current' if controller.controller_name.downcase == link.downcase
    nav_bar << "<li class='#{li_class}'>#{link_to link.capitalize, '/' + link.downcase, :class => link_class}</li>"
  end
  nav_bar
end

I’m calling this helper like this:

# layout
<%= main_navigation ['dashboard','messages','settings'] %>

Yes, each link does correspond to a controller, and the reason I’m changing the ‘settings’ tab is because I want it off to the right, separated from the other tabs. The concept is obvious, but this thing is acting crazy. Here’s what happens when I click…

  1. Dashboard—All three list items have class='left' and each tab has class='current'
  2. Messages—All three list items have class='left' but this time, the Dashboard tab has class='non-current'
  3. Settings—All three list items have class='right', and only the Settings tab has class='current' (which actually is the current section, making it the only one to follow the ‘current’ rule)

It seems like the li_class always applies to all three tabs, but the link_class doesn’t. Is there something blatantly wrong with this?

UPDATE—the only trouble I’m having is with the ‘left’ and ‘right’ settings. All tabs are left if I click on Dashboard or Messages, and all tabs are right if I click on Settings. I had the li_class and link_class being initialized outside the loop, like an ignoramus. But I can’t seem to get the settings tab to be the only tab with class='right'.

Useful tips when using Textmate

I don’t get to use Textmate (hopefully E will suffice), so I don’t know if these tips are even worth sharing. But you never know… just because I can’t benefit from them, doesn’t give me the right to hold you back.

Ruby Documentation

When you’re coding and you draw a blank on what the acceptable parameters are (strftime for example), in Textmate, with your cursor at the end of the method you can hit CTRL+H to bring up the RDoc for that method. It would probably take me a bit to get used to doing that, but I’m always referencing documentation, so I could see that being huge for me.

Finding your way around

Let’s say you’re inside of a controller method, if you hit OPTION+COMMAND+SHIFT+DOWN, you will be presented with a drop down to navigate to the associated files (views, helpers, etc) for that method. Seems to be a nice and easy way to navigate.

Displaying the Schema

If you’re in a model, and you need some DB table details, hitting CTRL+UP+OPTION+S will pop-up the schema for that model, displaying the column, primary key, data type, and default value.

Completions

You can use the ESC key to complete what you’ve typed so far, based on matches within the current document (handy if you use long, descriptive method names).

Refactor Partials

I am grateful for the ability to refactor partials. All you have to do is select the chunk of view that you want to convert to a partial, and hit CTRL+UP+H (I think this is possible in E, too). This will prompt you for a partial name, then replace your text with a <%= render :partial => 'the_name_you_chose' %>, and create the partial using the replaced text. Very useful.

Footnotes Plugin

The footnotes plugin throws up a simple footer allowing you to access and monitor everything around the current action and the application in which it resides. For instance, you can easily view (and edit) the controller, the template for the current action, the layout, and the JS. You can also view the session, cookies, params, and debug. This is only for Mac, but seems like it’s an unobtrusive way to monitor things in development.

Like I said, these tips may be very common to Textmate users (and why wouldn’t they be… I don’t even use Textmate and I know about them). Anyway, that’s just the tip of the iceberg. I’m not going to try and link to all the useful references for Textmate, but they are worth looking up—just Google it. And just today, Chris mentioned word of a new Textmate book that’s either out or is coming out soon, and it’s fairly cheap.

Ruby on Rails editors for Windows

So I’m still on Windows, developing in Rails. I’ve tasted a sample of Textmate, and from what I can tell, it’s undoubtedly the best editor I’ve used. I’ve been trying to find an editor similar, but for Windows. It’s a tough task, and while I’m aware that I won’t find one to match, I have found a couple that are close. Worthy of mention and in the order I prefer them, we have:

  1. e
  2. Intype
  3. RoREd

e is the latest of my findings, and seems to be very, very good. Yesterday was my first full work day using it (along with today), and I didn’t come across one single problem. And it supports Textmate bundles. One feature I particularly like (I’m not sure if Textmate has this) is the ability to CTRL+HIGHLIGHT multiple places within a file, and replace or add text simultaneously. For instance, say you had a private method you were calling five times throughout your class, and you realized you needed to add another parameter. You could CTRL+CLICK/HIGHLIGHT all of the places you needed to insert it, and then start typing—it fills them all in at the same time. I wasn’t sure if this would be handy, but I’ve used it a few times already. So far, it’s the winner.

Intype is still in an ‘alpha’ state, so it’s lacking a project view. However, it seems to be promising. It supports the Textmate bundles as well, but there are still a few things that bother me (such as setting the Tab = 2 spaces and it resetting upon restart). Someone built a project view plugin for it, but here’s the issue: any time you execute a request in your app (or commit your code), all of the folders collapse. That’s really irritating; so much, in fact, I simply can’t use it right now.

RoREd doesn’t really compare to the other two. There are a few handy ideas, but they simply weren’t executed well enough. For instance, the ability to group your files according to the Rails implementation of MVC. If you open schools_controller.rb, whenever you open the model and/or any associated view, they will open as sub-tabs under the “Schools” button. And you can do things like “open all related files” (or just the views, model, helpers, etc.) It also has quick buttons to load the console, server (webrick/mongrel), or a simple command window (to quickly run generators or create migrations). But the bottom line is, it’s relatively buggy, and cheap-looking. Plus you have to define your own sippets, which means I won’t use them.

Even though the name is dumb, e is my editor of choice right now. It does some pretty cool stuff, and I like the built-in themes. I’ve tried plenty of other options, but nothing jumped out at me (the .NET-looking Rails editors give me terrible flashbacks). So that’s about the best a person can do for RoR development on Windows, in my opinion.

A wise man once asked me...

...So you aren’t caching the API data? Hanging my head, I had to answer with a No. But I decided to look into that option, as it would remove the direct coupling of my site and the APIs, speeding things up a bit in the process. While you may or may not have noticed, the main page has been an arbitrary hit-or-miss the last couple of weeks. Sometimes it’s up, taking it’s normal 4-5 seconds to load, and other times (when the delicious response data is randomly empty) it would either hang or instantly die (hence, the direct coupling).

Yesterday after church, I finally sat down to work out the kinks. I was fed up with the slow loading and down time. Using the suggestions Chris proposed, I was able to get things going. I’ve never used the Marshal library before, so I didn’t know what to expect; but it turned out to be extremely straightforward. I also wanted to use pure Ruby (no Rails) in my script, so I had to tweak it a little.

I exported the inner-workings of the original methods that grabbed the flickr and delicious data, and put that processing in a Ruby script located in my script folder. As expected, a few things were no longer accessible, including the to_date method. I just used the Ruby libraries directly (such as Date.parse in place of to_date to convert the ISO 8601 format). And all was well.

So the script processes the API data and Marshal.dump’s it to the file system. Those previous methods now simply look for the cached file and Marshal.load it back in, rather than dealing with the API responses directly. Not only do I like this solution a lot more, I’ve cut the load time of the main page from 4-5 seconds down to < 1 second (checked against one of those web page analyzers).

So the core of all of this is working; however, I do still have a problem: automating the script to run on a 30 minute schedule. I have a cron job for this, but apparently it isn’t working. Here’s the cron:

*/30 * * * * /usr/bin/ruby ~/rpheath.com/site/script/api_cache.rb >/dev/null 2>&1

The job is listed there when I check with crontab -l, but I don’t think it’s doing anything. Once I figure that out, I’ll be good to go. Oh, and thanks to Chris for the idea.

I broke down and added a tag cloud

Last night (after Grey’s Anatomy—it’s a lot better than you’d think), I got the urge to build a tag cloud. Part of me saw it as useless, but part of me was still curious as to how it would represent the content. Plus, as we all know, programming is fun; so essentially there was no harm done (I wish that didn’t rhyme).

Firebug is awesome

Firebug has helped me out so many times. It’s probably the best tool I’ve used to assist me with development. If you don’t know what it is, here’s a video that illustrates Firebug and what it can do (warning: it’s close to an hour in length—I skipped through it).

A few more site improvements

Over the weekend, I spent a little time tidying things up a bit. Honestly, I think this has been the longest run for me and a single site. It turns out, a few of the original design ideas don’t really fit anymore; namely the archives and tags. Originally, both sections had a vertical list that had nothing to prevent them from reaching the core of the earth. For the archives, I’m now letting you view titles for a specific month. And by not loading all of the archives at once, it seems to help slightly on load time. As for the tags, the same problem existed. Plus, it wasn’t feasible to have them spread 750px (or so) away from their corresponding entry count. I’m debating an optional tag cloud view, mainly for two reasons: 1) that sort of visual understanding of the common topics may be useful (I’m kind of curious as to what it might look like) and 2) a tag cloud would be a good way to practice more Ruby code, as I’ve never written one explicitly.

And last but not least, I’ve finally found some time to incorporate the Syntax library. And I owe Chris Scharf for that (via his implementation)—thanks, Chris. For Textile, I had originally written a view helper to convert the text from the database at the instance of the view (to_html(content)). But after reading Chris’ post, I started using the before_save callback to save out the textilized text into another column. It’s much cleaner to say post.body and post.body_html depending on which one I need, rather than wrapping a helper around it each and every time. Plus it works nicely for Syntax, too. If you use Chris’ method, you should give credit back to him for posting how he did it. And while I’m in confession, I’ve temporarily adopted his CSS for the highlighting; I really do plan on changing it, though. In due time, I suppose.

(Trying to) run lighttpd in development

This morning I’ve been spending some time on the Mac trying to get everything setup for RoR development. I found a nice rake task that should handle the permission problems (since we develop in Windows and OS X now). And I believe I have MySQL setup correctly (although there are still some annoying user permissions there, as well). So that leaves me with the development server. We chose to use lighttpd because webrick is rather slow, and I’ve heard nothing but good things about lighttpd (but that still doesn’t mean it’s good). It’s installed and working correctly, but my issues are with the config/lighttpd.conf file. I specified the server.port = 3000, but what I don’t get is when I run the application on 3000, then stop lighttpd (Ctrl+C), I can no longer run it again on that port. The only way I can get it to startup again is by going to the config/lighttpd.conf file and incrementing the port (say 3001), which I’m well aware of as being ridiculous. So, how do you get lighttpd to use the same port all the time? Or maybe I’m not properly shutting it down, where it really is still running on 3000 (meaning Ctrl+C is not enough)?

Also, if I try to run webrick on a port I haven’t used (i.e., $> script/server webrick -d 3010), I get binding errors. Is there something I should change for that, too?

I believe the problems are narrowed down to the development server (and maybe MySQL). I really should look into sqlite3, but I don’t want to get too much on my plate at once since I’m new to this environment.

A new editor for RoR development

Hence the name, RoRED. Unfortunately, I’m in a Windows environment (although I don’t know that for sure, as I’ve never used a Mac). Aside from many other Windows drawbacks, I’m unable to get Textmate, which I’ve heard a lot about. I’ve been using RadRails for the past few months, but now it takes forever to load. I came from PSPad, so I was used to that quick, easy editing. I’ve been reluctant to even open RadRails lately, and that’s not how it should be. That’s a mood killer is what that is.

I figured there were more editors out there so I began to look around. I tried jEdit, but came across a few problems that led me in the opposite direction. Then I found RoRED. It’s light-weight and has a few nice features. Features that promote productivity, which are the kind I like. It supports this MVC view, where it groups models, views and controllers in a smart tab type of interface. I think I like it. Also, it supports a “go to definition” by CTRL+Clicking on a method name, which can be handy. One thing I knew I wanted in my next editor was autocomplete functionality, which it supports. An autocomplete (or abbreviation) let’s you type a pre-defined string of characters and transform that string into a block of code that you’ve set by hitting something like CTRL+ENTER or SHIFT+SPACE. For instance, a recent one I’ve added:

# simply type:
dtxs SHIFT+SPACE

# to get:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
    "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en">
<head>
    <title></title>
    <meta http-equiv="content-type" content="text/html; charset=iso-8859-1" />
    <meta name="Author" content="Ryan Heath" />
</head>

I chose dtxs for “doctype xhtml strict”. So by typing four little letters and hitting SHIFT+SPACE, I get all of that code with my cursor blinking between the title tags. I know this has been around for a while, but this will be my first encounter with any form of autocomplete or abbreviation(s). One thing I don’t like is the fact that you can’t tab your cursor to the next marker (place you need to type) like you can in Textmate and jEdit. For instance, I have one for link_to. Well, a link_to has at a minimum a name and action, but I cannot mark the spots for both. Here’s what it takes to define the abbreviation in RoRED:

# How to define the abbreviation:
[lt | creates a rhtml link_to with action only]
<%= link_to '|', :action => '' %>

# Once defined, type "lt SHIFT+SPACE" to get:
<%= link_to '', :action => '' %>

Notice the ”|” between quotes in the definition? That’s where your cursor will go after typing lt SHIFT+SPACE. If I were to put another ”|” in the quotes for the action, it would literally show up and I’d have to remove it and type my action name. Where in other editors, you can do something like:

# How to define the abbreviation:
[ltcai | creates a rhtml link_to with controller, action, id]
<%= link_to '$1', :controller => '$2', :action => '$3', :id => '$4' %>

# Once defined, type "ltcai SHIFT+SPACE" to get:
<%= link_to '', :controller => '', :action => '', :id => '' %>

So your cursor starts out where the $1 is, but you can tab directly to the next spot in line filling it in as you go. It’s hard to imagine me complaining already, but I think I really will want that functionality. It seems that I’m inadvertently trying to get rid of my mouse altogether. Anyway, overall I think RoRED will be a nice switch for a while.

How to build for scalability

Maybe you were thinking this was going to be a tutorial or a methodology for good practice, but it’s actually quite the opposite. I agree that scalability is extremely important, but I don’t exactly know what it means to “build for scalability.” Well, I know what it means, or at least the point is made, but how do you do that? What would I want to do differently? I’ve read a number of times that you should “worry about your users once you get them; just set your app up for scalability.” It seems like it’s a hardware issue, but I’m sure it’s more than that. Maybe by building a service-oriented application, you can eventually host each “service” on a separate, dedicated machine to handle large amounts of traffic? I’ve looked it up and read a little bit about it, but nothing jumps out at me to claim that I know how to do it. Surely it’s more than optimizing SQL queries. Luckily for me I don’t have (nor am I involved with) an application that requires sound scalability.

The respond_to option in Rails

See, this is the type of thing I sometimes don’t realize. I haven’t used respond_to in any of my applications, and I’ve implemented quite a bit of Ajax (not that respond_to is solely used for Ajax). And for the record, I’ve never attempted to write my very own REST web-service in Rails. I’ve requested other web-service’s, but I’ve never supplied an API. But it’s seemingly ridiculous to not include it in some of the things I do. You know, just in case. And if nothing amounts of it, at least I’ll know what needs done if I ever do need to do it.

There are two ways I’ve dealt with Ajax in Rails: the 1.0 way of render_without_layout and the 1.1 way of RJS. In either case I had an extra method (which means an extra template/view) to handle the Ajax response (I also wasn’t aware of xhr?). So, what resond_to is trying to tell me is that I can use the same method/action for regular post-back’s, Ajax request’s, and REST requests??? And not to mention it’s only 5 (or so) lines of code? That’s quite impressive, unless of course, I’m not stating things correctly. From all that I’ve read, I’ve somehow missed the boat on the respond_to option. I think I noticed it a time or two, but never dug deeper—it looks very handy. Are those three classifications (html, js, xml) the main usages with respond_to, or are there more?

Agile Web Development with Rails

As you might know, I’m on this kick to know Rails better. I’ve already read AWDWR once, but I think I might read it again. I read it as my introduction to all of it: MVC, Ruby, and Rails. I don’t think that’s fair to the book. While it was good at the time, I think the second reading will really sink in. For whatever reason, I feel like I’ve missed something along the way. Something that could/would help me write cleaner code. We’ll see. Maybe I’ll wait for the second edition (releasing early December?) I could read them both I suppose, but that would be mighty ambitious of me.

Compiling HTML in the browser

I do the best I can with keeping the sites I build standards compliant. I’m far from an expert on the subject, but at least I’m aware there are standards. And for those who aren’t, sites like A List Apart and Digital Web (among others: Mezzoblue, Standards for Life, 456 Berea St., etc.) always have detailed, quality articles promoting standards.

About 3 years ago, I really began to focus on validating my markup. As a boring person who makes websites, I find satisfaction in standards. Satisfaction in knowing that I built a site how it’s supposed to be built, and then got a check mark at the end telling me I’m following the rules. It’s like getting every question right on a 200 question test—it just feels good. What I don’t get is how someone could be exposed to standards and ignore them. A web developer who really, truly likes what they’re doing (web development seems to be an area you choose to enter) should want to follow the rules. It’s the upmost important thing relating to the “correct way” to do their job. Everyone wants to be good at what they do; I don’t see why this effort falls short so often.

So, why not compile HTML in the browser based on the DTD, and not let the HTML render unless specific actions are taken? I know, that’s completely radical and unrealistic, but I don’t think I would have a problem with it. I’d even learn from it. It would take centuries for the new standards to propogate and be reflected in browser versions (they don’t even do it correctly as it is), but in a utopian world it would ensure that people do their jobs correctly. Then again, in a utopian world, we wouldn’t have to worry about this in the first place.

It’s like recycling – it sure does sound good, but when it comes down to rinsing out the milk jug, the majority simply doesn’t do it. The result? Waste gets landfilled or incinerated, causing the whole world to suffer. If more people would quit putting glass and plastic (<font> and <table>) in their trashcans (websites), we would all benefit. Seriously, though—there’s nothing attractive about a non-conforming-to-standards site, just like there’s nothing attractive about global warming. If you don’t (or at least try to) follow web standards, I suggest you clean up your act.

Making some needed improvements

As I stated in my previous post, I’ve been looking into some optimization options for my site. Things like page caching especially drew my attention, but then I realized something. If I step back to a design standpoint and think logically, I noticed a lot of unecessary things going on. Before I continue, I should mention I didn’t make any vast improvements on the slow API request issue, but I since converted my del.icio.us integration into a much easier solution: the rubilicious gem. It’s slightly faster and much cleaner. I tried going back to the flickr gem (since I’m running a frozen version of Rails now), but kept getting “Invalid API Key (Key has expired),” or something along those lines. Both of my developmental API keys for Flickr are, in fact, active. But it looks like I’m not the only one with this problem. Needless to say none of those solutions worked for me.

Back to what I was saying. Since the APIs bog down the site, are they really needed? Well, no, but that wasn’t an option. However, it isn’t needed on every page. I’d say some people read my posts in a feed reader. In that case, if they feel compelled to comment, they probably do a CTRL + click (or a mouse-wheel click) to open a new tab (assuming those who comment DO NOT use IE, which may or may not be accurate) and go directly to the entry. This is much faster for those people. I can see putting popular tags and categories in a common layout for convenience, but it boiled down to a design decision, and I simply didn’t want to. There’s a link to search available in the footer throughout, so that’s close enough.

Finally, I didn’t like the two column layout. So while I was motivated enough to make some adjustments to the code, as usual, I made some adjustments to the CSS. I like the open feel of an entry consuming a page. After all, aside from people like me, most visit sites to read/view content. That’s much easier to do when it’s the only thing drawing your attention. So, I’ve rolled out version 2 instead of starting over. It’s a little out of character, I know, but I’m proud of myself.

Optimizing rpheath.com

Lately I’ve been looking into optimizing my site a little bit. It’s annoying how slow it is. It’s all because of the two APIs. I’ve brushed up some of the database queries but you can barely tell, if at all. I’m aware that the APIs are causing the site to bog down a bit, so I’ve been looking into alternative ways to get the data. Currently, I’m creating the requests and parsing the data out manually, but other libraries and gems (such as flickr.rb) probably handle it better than I do. Also, I knew Typo comes pre-packaged with various API capabilities, so I downloaded the source to check it out. I noticed they have a delicious.rb file located under an “aggregations” folder in the models directory. What is the idea behind this? Is this something you install/setup? If so, what is the benefit of doing this? Also, I don’t know that Typo code is the most efficient interface to the del.icio.us API, but I’m sure it’s better than mine. I got this quote from the wiki: “Aggregations let you access attributes on an ActiveRecord object through sort of proxy objects.” I kind of get that, but it’s not clear-cut to me. I’ll be looking into it, but I thought I might get a response or two that may be a bit clearer. Any other thoughts on optimization (other than removing the APIs completely)? What about a form of caching? I’m unfamiliar with techniques to improve effeciency and speed.

Becoming familiar with Subversion

I have finally taken the time to learn a little bit about Subversion – it is now a part of my development process. I’m getting into the habit of committing frequently—it’s the first thing I think of once I make decent progress. I don’t know what’s considered “frequent,” but I us