development full of
merriment and sense

RESTful Rails and Dreamhost

Geoffrey on December 17, 2007 at 11:33 am

I recently upgraded StagingTracks.com to use Rails 2.0. I was excited about so many of the newest features that it seemed the logical thing to do. I even decided to upgrade RSpec in the process so I would be able to play with some of the new features there too.

Unfortunately, despite extensive local spec’ing, when I deployed the app to Dreamhost, things did not go as planned. I was using piston to manage my Rails in the app and all of my plugins, so I didn’t need to worry about which gems were installed on the server. What I found was that when users tried to submit new information using the forms on the site, nothing would happen. Let me correct that: It would look like something happened, but no data was submitted.

So what was the problem?

I first started by watching the production.log to see if the data was even getting submitted. As expected, nothing was coming through. I then used the Tamper Data plugin for Firefox to see if I if the data was getting out of the browser. It was, but something interesting appeared. I saw a 301 Redirect when the page was submitted. Odd. Especially since the application wasn’t seeing the data and there were no redirects in the production.log.

So I started looking in the http access.log to see why the data wasn’t coming through to the app. What I saw was surprising:

- - [16/Dec/2007:19:24:30 -0800] "POST /shops HTTP/1.1" 301 591 "http://www.stagingtracks.com/shops/new" "Mozilla/5.0 (Macintosh; U; Intel Mac OS X; en-US; rv:1.8.1.11) Gecko/20071127 Firefox/2.0.0.11"
- - [16/Dec/2007:19:24:30 -0800] "GET /shops/ HTTP/1.1" 200 319 "http://www.stagingtracks.com/shops/new" "Mozilla/5.0 (Macintosh; U; Intel Mac OS X; en-US; rv:1.8.1.11) Gecko/20071127 Firefox/2.0.0.11"

It looked like the POST (which goes to the ‘create’ method using Rails RESTful approach) was being redirected to ‘/shops/’. The browser would then call ‘/shops/ ‘ with a GET (which is the ‘index’ action). And the form submission never got through. Now I was perplexed. Why would the web server being sending the 301 Redirect?

It became a little clearer when I saw this in the logs as well:

- - [16/Dec/2007:19:15:11 -0800] "GET /shops HTTP/1.1" 301 591 "http://www.stagingtracks.com/" "Mozilla/5.0 (Macintosh; U; Intel Mac OS X; en-US; rv:1.8.1.11) Gecko/20071127 Firefox/2.0.0.11"
- - [16/Dec/2007:19:15:11 -0800] "GET /shops/ HTTP/1.1" 200 89174 "http://www.stagingtracks.com/" "Mozilla/5.0 (Macintosh; U; Intel Mac OS X; en-US; rv:1.8.1.11) Gecko/20071127 Firefox/2.0.0.11"

For some reason, the web server was causing 301 Redirects when the trailing slash was missing! Now I had heard of the trailing slash problem, but couldn’t find a suitable solution that would be easy to implement.

So How Do You Fix It?

I am so glad I am surrounded by lots of smart people. A quick conversation with my friend Rob Sanheim turned up the solution.

I added the following to my .htaccess file:

DirectorySlash Off

I added it after the Options +FollowSymLinks +ExecCGI and before the RewriteEngine On

Now things are back to normal again. I am now able to get back to connecting model railroaders.

Filed under: Rails, RSpec, Web Applications, Web Development, Dreamhost

Lightning Talks at Dallas.rb

Geoffrey on August 31, 2007 at 10:56 pm

Lightning
photo by anyoungkevin

We are doing lightning talks at this month’s dallas.rb meeting. I decided to give the group some choice of what I would present.

I will do a short one on “Why Firefox Makes Me Look Good” or “Better Web App Development using Firefox and a Buttload of Extensions”

I can also do one “JQuery: I Don’t Know Much, But I Know I Love You

And since neither of those are Ruby related, I will throw another one out there: “Tighter Abs: XML Situps Made Easy With Ruby”

I’ll let everyone decide which ones you want to hear more about.

Update

I only did the JQuery presentation and here are the slides (although they were much more interesting in person).

Filed under: Rails, JavaScript, Ruby, Web Applications, xHTML, Dallas, JQuery, Development Environment, hpricot, Firefox, Firebug, Web Developer Toolbar, Web Development

Design Patterns for the Web

Geoffrey on July 18, 2007 at 8:20 am

Blueprint
photo by tifotter

I came across the Yahoo! Developer Network: Design Pattern Library recently and was impressed with the number of patterns they had. It has been out for a while now, but I am just now getting back to checking it out. Definitely a useful resource.

Filed under: CSS, Web Applications, xHTML, Usability, Accessibility, Web Development

Is That Really What It Looks Like?

Geoffrey on May 14, 2007 at 7:41 am

Marshall, Deputies, and Engineer

photo by texas_mustang

One of the things I like about taking a project from start to finish is the first few rounds of development where we hammer out what the application is supposed to do. After reading Kathy Sierra’s article “Don’t Make the Demo Look Done, I wanted to see if I could come up with something similar to the Napkin Look and Feel for my web applications.

Why is it important? I have found out the hard way, what Joel Spolsky points out in The Iceberg Secret, Revealed. As soon I start putting the colors, graphics, and drop shadows in place for the finished product, the attention is no longer on the functionality of the application and now turns to “could you move that button over 5 pixels?” And this is still while half the application remains unfinished!

So this is my interpretation of making the demo look like a demo. It is completely driven with a separate CSS stylesheet that can be removed and replaced with the finished stylesheet. I make use of the Yahoo CSS and some paper background images. I have even contemplated making use of the Tongue In Cheek icons to make it even more authentic. I would have used a handwriting font, but there is not a good cross browser way to deliver fonts, so Comic Sans will have to satisfy the prototype font requirement.

Here are what the initial screens look like for a new application:

  • Home Page Prototype Home Page
  • Sample Page Prototype Sample Page
  • Sample Page Another Sample Page

Does it work?

So far it has worked great. And as soon as we switch stylesheets, we lose focus on the functionality. Every time. So I will keep using this and keep pushing this as far as a project will let me.

Filed under: Projects, CSS, Web Applications, Entrepreneurial, Usability, Web Development, wireframing

Why Firefox Rocks For Web Development

Geoffrey on May 8, 2007 at 9:47 pm

Because my friend Matt was so impressed with a Firefox extension I showed him, I thought I would share some of my other favorites.

Wild West Railroad
photo by longhorndave

What Extensions I Am Using Right Now

  • Web Developer Toolbar - Just about everything you could want to do HTML and CSS, plus I can edit AND save the CSS changes I was playing around with.
  • Firebug - So much goodness. Especially debugging JavaScript and looking over AJAX requests and responses.
  • View Source Chart - Makes looking at HTML source bearable.
  • ColorZilla - a color picker for pulling colors off of web pages.
  • HTMLValidator - because it is too easy to miss a closing tag somewhere that messes everything up.
  • DummyLipsum - when you need some filler content.
  • SeleniumIDE - great little utility for helping to write Selenium tests for functional testing.
Big Thunder Mountain
photo by meshmar2

Not to mention

Got a favorite? I’d like to hear about it.

Filed under: JavaScript, CSS, Web Applications, xHTML, Testing, Development Environment, Firefox, Firebug, Web Developer Toolbar, Web Development, Selenium

Powered by WordPress