Lots of Rails developers having coffee

Thijs van der Vossen, 31 Mar 2006, 14:21 in ruby on rails and events (edit).

When we proposed a Rails meeting two weeks ago, we thought we’d be having coffee with 4, maybe 5 fellow developers from Amsterdam. We never expected more than 30 people to show up, certainly not people all the way from Eindhoven, Venlo or Groningen!

It was a lot of fun chatting about Rails with all of these people. Please leave a comment if you’d enjoyed the meeting too.

We’re currently planning another fun event for Rails developers. We’ll post more information about it as soon as we get some things confirmed.

Update: You can find some photos here and here. For more comments on the meeting, see this, this and this post (all dutch).

6 comments

Rails ‘morning coffee’ meeting FAQ

Thijs van der Vossen, 23 Mar 2006, 14:30 in ruby on rails and events (edit).

There’s a lot of interest in the Rails meeting we proposed last week.

We’ll answer some of the questions that keep coming up.

Wouldn’t it be kinda busy?

Yes, probably, but we don’t think it will be too crowded.

I have to leave very early because I’m coming from Venlo/Groningen/someplace else far away. Can’t you start later?

Please remember that this is nothing more than an informal meeting at a regular coffee bar. It’s not a conference or seminar, there are no speakers or workshops.

It would be great if you could make it, but please keep in mind that there will be nothing more to it than buying a cup of coffe and having a good chat about Rails.

Will it be easy to park my car there?

No, parking in Amsterdam is never easy. See bereikbaar amsterdam for more information on where and how to park your car.

How do I get there from the central station?

Take tram 4, 9, 16, 24 or 25 and get out at the Muntplein. Cross the bridge to hotel de l’Europe. You’re now on the nieuwe Doelenstraat where you’ll find the Coffee Company after 100 meters on the right side.

No comments yet

Handheld stylesheet

Thijs van der Vossen, 23 Mar 2006, 12:29 in web and design (edit).

One of the advantages of designing with web standards is that it doesn’t take much effort to create a mobile version of your website. It took me just a little more than an hour to add a stylesheet to Rijnboutt van der Vossen Rijnboutt that optimizes the layout for handheld devices.

No comments yet

Rails ‘morning coffee’ meeting in Amsterdam

Thijs van der Vossen, 17 Mar 2006, 11:49 in ruby on rails and events (edit).

In the last few months we found that there are more and more Dutch people working with Ruby on Rails. So far we’ve kept in touch by email and instant messaging, but now we’d like to meet up in person. Our goal is to have a good chat about our experiences with Rails, and of course a strong cup of coffee is a precondition for such a thing.

When: Thursday, March 30th, 2006, 9:30 AM

Where: The Coffee Company on the corner of the Nieuwe Doelenstraat and the Kloveniersburgwal in Amsterdam

This is an informal meeting intended for people working with Rails, developers and designers who want to get started, and everyone wondering if Rails might be a good fit for their project.

Please leave a comment to tell us you’ll be there or if you have any questions.

Update: We’ve answered some of the questions that keep coming up in this post.

51 comments

Monitoring and managing fcgi processes using fcgimon

Manfred Stienstra, 16 Mar 2006, 17:25 in ruby on rails and tools (edit).

When we started using Switchtower Capistrano to deploy our projects, we had some trouble with Lighttpd herding the fcgi processes. Because the standard Capistrano tasks expect the processes to be managed externally anyway, we decided to stop using Lighttpd for this.

Most of the existing tools for managing fcgi processes are designed to do complex stuff like load balancing across different servers. What we needed was a simple tool for managing multiple Rails applications on a single server. So we wrote Fcgimon.

Fcgimon manages fcgi processes using the spinner and spawner scripts that come with Ruby On Rails.

FCGIMon screenshot

You specify all Rails applications and the number of fcgi processes you want to have running in a configuration file. Then use fcgimon to start or stop all fcgi processes for any single application, or start and stop all applications at once.

Fcgimon also generates snippets that can be included in the main Lighttpd configuration file. This makes it much easier to keep the number of running fcgi processes and the ports listed in the Lighttpd configuration file in sync.

You can download the latest version of Fcgimon from our Subversion repository. Please give it a try and tell us what you think.

2 comments

Pair programming

Thijs van der Vossen, 10 Mar 2006, 14:41 in practices (edit).

Martin has taken some baby steps toward pair programming. One thing holding them back is that they work on al lot of different projects, so it’s rare for two people to be assigned to the same thing.

Although we’ve taken a lot of our practices from Extreme Programming, we don’t do full-time pair programming for much of the same reasons. I don’t see how pairing is going to help me when I’m designing a user interface, or when I’m doing server maintenance.

Having said that, we find ourselves programming in pairs more and more often. It really is much faster to solve complex problems together. It also works great for refactoring, because it’s much easier to keep track of all the changes when you’re working as a pair.

The only problem with pair programming is that it’s hard to explain to people who have no experience with it. Why would you want to have two programmers working on something that one can do alone? Isn’t that just wasting valuable programming hours?

Although there is a lot of evidence suggesting that it’s not, we’ve sidestepped the issue somewhat by only pairing for short periods of time when it’s really clear that it helps the project going forward.

No comments yet

Attaching files to new messages

Thijs van der Vossen, 09 Mar 2006, 10:39 in ruby on rails (edit).

I really love Basecamp, but there’s this little issue with attached files that keeps biting me. The problem is that the url of the file changes after you’ve saved a new message.

So, I’m working on a design, and I’d like to show it to my client. After I upload the file, I copy the url by right clicking its link. Then I paste the url with formatting codes that include the image in the message body:

After I post the message, the image is missing:

So I click ‘Edit’ to find out what I did wrong. As you can see, the url for the attached file has changed. I copy and paste the new url in the message body:

And now it works:

What probably happens is that uploaded files are saved to a temporary location when you’re working on a new message. You have to post the message before a message object is created. Only after a message object has been created, is there a message id where attachment objects can be linked to. The problem is that you simply can’t link the uploaded files to a message that doesn’t yet exist.

Please note that this is a completely sensible solution for this kind of application; I’m probably one of the very few people who likes to include images inside the message body.

When you write an application for managing the content of a website this is much more of an issue. The people who publish articles on their website are very likely to want to include images.

For simple systems, we often take the easy route. You first have to save the article as a draft:

Only then can you attach and include images:

For more complex systems, we’ve solved this problem by saving a record for the article to the database right after you click ‘Add article’ so that we always have an article id to link the attachments to.

These articles have a status attribute that is set to ‘new’. The status is changed to ‘draft’ or ‘published’ after you save the article. If you don’t save a new article, it gets garbage collected within a few days.

This is what the relevant parts of the article model look like:

class Article < ActiveRecord::Base
  has_many :assets, :order => :position, :dependent => true

  def self.collect_garbage
    resources = Resource.find :all, :conditions => "status = 'new' AND
      created_at < DATE_SUB(NOW(), INTERVAL 7 DAY)"
    resources.each {|resource| resource.destroy}
  end
end

Article.collect_garbage is called in the list action of the article controller, but you could also use a cronjob of find some other way to call it regularly.

This is what the relevant parts of the article controller look like:

  def new
    @article = Article.new
    @article.save
    redirect_to :action => 'edit', :id => @article.id
  end

  def edit
    @article = Article.find(params[:id])
    if request.post?
      @article.attributes = params[:article]
      if params[:upload]
        # handle asset upload
        asset = @article.assets.build
        if asset.handle_upload(params['asset'])
          asset.save
          flash['highlight'] = "asset#{asset.id}"
        end
      else 
        # handle article submit
        if @article.save
          flash['highlight'] = "article#{@article.id}"   
          redirect_to :action => 'list'
          return false
        end
      end
    end
  end

You can view an example of how this works (Quicktime).

No comments yet