Slides and Materials from “Web Design for Programmers”

Posted by Brian in News, web (June 4th, 2008)

The slides from my RailsConf 2008 tutorial session are now available. Grab the PDF version.

Unfortunately, the handouts I sent were printed in black and white so some of the color examples don’t work as well. Grab color ones instead.

If there are additional materials from the presentation that you want to see, let me know and I’ll see what I can do.

Create a new Edge Rails project

Posted by Brian in News, Rails, snacks (April 24th, 2008)

In a previous post, I provided scripts that made the creation of a new Edge Rails project easy. Since then, Rails has moved from Subversion to Git, which means that the scripts I provided no longer work as expected. Fortunately, very little has changed and I was able to make the script a little bit better so that it acts like the original rails command.

Prerequisites

First, you’re going to need git. I could have written the script to grab the latest version via a zipfile, but I wanted something that was fast and worked on all platforms. Windows can unzip files, but then I’d have to make Windows users go grab commandline tools to unzip files.

Installing Git

Mac users with XCode and Macports installed can do it with

sudo port install git-core +svn

Windows users can install Msysgit.

Linux users should install Git using their package manager or from source.
Here’s the script. Instructions for running it are after the code.

#!/bin/ruby
git_repo = "git://github.com/rails/rails.git"

help = %Q{
Rails Info:
    -v, --version                    Show the Rails version number and quit.
    -h, --help                       Show this help message and quit.
 
General Options:
    -p, --pretend                    Run but do not make any changes.
        --force                      Overwrite files that already exist.
    -s, --skip                       Skip files that already exist.
    -q, --quiet                      Suppress normal output.
    -t, --backtrace                  Debugging: show backtrace on errors.
 
Description:
    The 'edge_rails' command creates a new Rails application with a default
    directory structure and configuration at the path you specify, using the
    very latest version of Rails.
 
Example:
    edge_rails ~/Code/Ruby/weblog
 
    This generates a skeletal Rails installation in ~/Code/Ruby/weblog.
    See the README in the newly created application to get going.    
 
}

require 'fileutils'
 
if ARGV.empty?
  puts help
  exit
end
 
dir = ARGV.shift
args = ARGV.join (" ")
 
FileUtils::mkdir(dir)
FileUtils::mkdir("#{dir}/vendor")

puts "Exporting EdgeRails from #{git_repo}"
# system "svn export http://svn.rubyonrails.org/rails/trunk #{dir}/vendor/rails"
system "git clone --depth=1 #{git_repo} #{dir}/vendor/rails"
system "rm -rf #{dir}/vendor/rails/.git*"
 
system "ruby #{dir}/vendor/rails/railties/bin/rails #{dir} #{args}"

How this works for Mac and Linux users

Save the script to your home folder as edge_rails, and set the execute bit:

  chmod 644 ~/edge_rails

Run it with

  ~/edge_rails your_app

You could symlink it to your /usr/local/bin if you are feeling clever.

How this works for the Windows crowd

Save this script as c:\ruby\bin\edge_rails.bat

@echo off
goto endofruby
#!/bin/ruby
git_repo = "git://github.com/rails/rails.git"

help = %Q{
Rails Info:
    -v, --version                    Show the Rails version number and quit.
    -h, --help                       Show this help message and quit.
 
General Options:
    -p, --pretend                    Run but do not make any changes.
        --force                      Overwrite files that already exist.
    -s, --skip                       Skip files that already exist.
    -q, --quiet                      Suppress normal output.
    -t, --backtrace                  Debugging: show backtrace on errors.
 
Description:
    The 'edge_rails' command creates a new Rails application with a default
    directory structure and configuration at the path you specify, using the
    very latest version of Rails.
 
Example:
    edge_rails ~/Code/Ruby/weblog
 
    This generates a skeletal Rails installation in ~/Code/Ruby/weblog.
    See the README in the newly created application to get going.    
 
}

require 'fileutils'
 
if ARGV.empty?
  puts help
  exit
end
 
dir = ARGV.shift
args = ARGV.join (" ")
 
FileUtils::mkdir(dir)
FileUtils::mkdir("#{dir}/vendor")

puts "Exporting EdgeRails from #{git_repo}"
# system "svn export http://svn.rubyonrails.org/rails/trunk #{dir}/vendor/rails"
system "git clone --depth=1 #{git_repo} #{dir}/vendor/rails"
system "rm -rf #{dir}/vendor/rails/.git*"
 
system "ruby #{dir}/vendor/rails/railties/bin/rails #{dir} #{args}"
__END__
:endofruby
"%~d0%~p0ruby" -x "%~f0" %*

Now, open a new command prompt and type

edge_rails my_new_app

If it doesn’t work, check that you have Git installed properly and have added Git’s command line utilities to your path.

Reverse Proxy Fix 1.0.5.0 released

Posted by Brian in News, Rails, Products (March 7th, 2008)

The reverse_proxy_fix plugin allows a Rails application to live behind a proxy like the one provided by HeliconTech’s ISAPI_Rewrite plugin as outlined in Deploying Rails Applications. It allows you to configure the base URL that will be prepended to any URL generated by the Rails link_to method and friends. This is useful if you want to force all requests through a frontend or if you want to graft your Rails application onto an existing IIS URL scheme.

This release fixes an issue with named routes and Rails 2.0. Previous versions of the plugin did not support rewriting of named routes in Rails 2.0 due to the optimization code for named routes. This version of the plugin disables the optimizations.

Installation

Installation is simple:

  ruby script/plugin install http://svn.napcsweb.com/public/reverse_proxy_fix

Then provide your base URL, which is the URL you want prepended to all of your URLs. For example, if you are trying to mount your Rails application at http://www.mydomain.com/myapp, you’d enter that as your base URL.

Next you need to specify which version of Rails you are using.

Comments are welcome, and so are patches if you see something that doesn’t make sense.

mongrel_service broken on Windows again.

Posted by Brian in News, Rails (January 1st, 2008)

If you’re working with the mongrel_service gem then you should know that right now there’s a few kinks in the system.

Here’s a quick rundown of the setup for Rails on Windows from scratch:

Download the One Click Ruby Installer and run the setup program.

Open a command prompt and type these commands:

gem update --system
gem install rails
gem install mongrel
gem install win32-service -v '0.5.2'
gem install mongrel_service

The key to this is that the win32-service gem is currently broken, so switching to a previous version (0.5.2) works great for us. Credit for this goes to Luis Laverna, the creator of the mongrel_service gem. See the discussion.

reverse_proxy_fix 1.0.4.1 released with Rails 2.0 support

Posted by Brian in News (December 18th, 2007)

I’ve been testing this release for about two months but had not released it yet. A friendly email from a user of this plugin alerted me to the fact that I should really push this release out, especially as it’s featured in Deploying Rails Applications

Reverse_proxy_fix is a plugin that prepends the base url of your choice to any of the URLs generated by Rails’ URL helpers. It’s primarily designed to allow you to hide your application behind a reverse proxy like ISAPI_Rewrite for IIS, though I’ve heard that people have used it elsewhere.

Say you have an app that you want to host on an IIS machine at http://www.myexample.com/fun/application

You’d install this plugin and configure it to use http://www.myexample.com/fun/application as your base URL. When you run your application in production mode, all of your URLS will be prepended with http://www.myexample.com/fun/application.

To install, you need to do the plugin install thingy:

ruby script/plugin install http://svn.napcsweb.com/public/reverse_proxy_fix

When the plugin installs, you then get to configure it with an interactive script.

########################################################
# reverse_proxy_fix plugin                             #
# Configureation                                       #
########################################################
 
Enter the base url you wish to use without the trailing slash (example: http://e
xternal.mycompany.com/myapp)
http://www.project.com/app1
Please select your Rails version from the list of supported versions:
 1 : Rails 1.1.6
 2 : Rails 1.2.X
 3 : Rails 2.0
3
The file C:/projects/rscrum/vendor/plugins/reverse_proxy_fix/lib/config.rb has b
een modified. The plugin will be activated when you run your application in prod
uction mode.
Plugin successfully installed and configured

ScaffoldForm Generator

Posted by Brian in News, Rails, Products (November 4th, 2007)

I’m happy to announce the release of the ScafoldForm Generator plugin for Rails. This plugin takes the most useful piece of scaffolding, the form creation, ad makes it available as a separate generator.

You can install it with

  sudo gem install scaffold_form_generator

Then just generate the forms for your models

ruby script/generate scaffold_form Project project
ruby script/generate scaffold_form User accounts

You can read more at http://scaffoldform.rubyforge.org/
.

There are a few neat tweaks I made to it to make the forms a bit more useful.

Eclipse for Rails updates

Posted by Brian in News, Rails, Products (August 27th, 2007)

We’re gearing up to release one more version of Eclipse for Rails. It should be available this week. It will include support for some Rails 2.0 features such as the new scaffold generator, updated templates, and updated templates. Of course, there’ll also be an update to the Eclipse core.

The space for Windows-based IDEs is filling out nicely. The folks behind the NetBeans Ruby IDE really have something they can be proud of and I am considering ceasing further development of the standalone Eclipse For Rails package. What do you think?

We’re sponsoring the Rails Rumble

Posted by Brian in News, Rails (August 27th, 2007)

The Rails Rumble (http://www.railsrumble.com/) is coming up. Flex your development muscles and create an application in 48 hours. Go it alone or get a team of four together to build something incredible. The contest takes place September 8th and 9th, 2007. Registration opens at 12:00 EDT on August 28th, 2007.

We’re giving away a 30GB Ipod choice of an 80GB iPod classic or an 8GB iPod Touch to the person who develops the best app all by themselves.

We’re doing audits too!

Posted by Brian in News (July 17th, 2007)

I’ve noticed that some other firms are starting to market this service, so we’re throwing our hat in the ring too. We’ve been doing this as part of our consulting for about a year now, helping a couple of teams learn how to write better code. This is the next logical step.

It never hurts to have a second set of eyes look over your code before you roll out that brand new application. I routinely have others look over my code before I release it because I know I’m going to miss something. Whether you hired out the project or did it yourself internally, you just might benefit from this service.

We’ll look for things like security vulnerabilities, code that’s not covered by tests, and help you identify trouble spots with your app long before your customers find them.

Contact us today to see how we can help.

RailsConf 2007 and presentation

Posted by Brian in News (May 21st, 2007)

RailsConf2007 was fun. I hoped for more advanced panels, as it really seemed to be geared towards beginners. There were some excellent talks though, and I did learn some exciting things.

For those of you who attended my presentation, thanks for the great support. Your questions and enthusiasm really made it worth the effort. I hope to be able to make the screencasts available soon, complete with annotations and a voiceover.

It was also great to meat Jeff Cohen and the Softies guys. That was probably my favorite part of the conference because they were the friendliest bunch of people who actually seemed interested in talking to and learning from others. We had a great conversation and I would love to work more with them.

Next Page »