Active Record 3.0

by Melvin Ram

Pratik has interesting post about what is coming on Active Record 3.0:

http://m.onkey.org/2010/1/22/active-record-query-interface

{ 0 comments }

Twitter has launched a lists feature (not sure when) and I didn’t find a list that consisted primarily of the Rails Core team so I’ve created one:

http://twitter.com/railsnotes/rails-core

{ 0 comments }

RailsEnRails 2009 has begun and attendee George Chatzigeorgiou has a nice summary of what was discussed. The most interesting bit on the page was Jeremy Kemper mentioning that the Rails 3 release date will likely be in the first quarter of 2010, or even before Christmas 09 if things go really well. Woo Hoo!

For the last few months, I’ve been busy with my web design company and haven’t had as much time to work with Rails as much as I’d like. However, that will be changing here shortly as I’ve got some internal projects that I’ll be building with Rails so I’m going to start learning & documenting how edge Rails works. Fun times ahead!

PS: I’d like to say thank you to New Relic for supporting this blog by covering our hosting costs. They provide a valuable service with their RPM service. If you’re not familiar with it, check it out. It’s free and will help you identify performance problems.

{ 0 comments }

The Hacking Ruby on Rails prezo by Heiko Webers looks like it has some interesting slides.

{ 0 comments }

istock_000000152791xsmallEarlier today, I noticed a bunch of weird requests to one of my Rails apps. I’m not sure what their intention was but I didn’t want to take the chance since the IP traced back to somewhere in China which meant if something went bad, I’d have little recourse.

So I decided to block their IP. Doing this is pretty easy using iptables on Ubuntu. I just entered this in my terminal after logging in via ssh:

iptables -I INPUT -s 59.56.108.202 -j DROP

I’m not sure if this is the best defense but it’s what was suggested by the support rep at Mosso. And yes, that is the IP I blocked. It was creating requests that looked like this in the access.log:

sitespress.com:80 59.56.108.202 - - [27/May/2009:17:32:25 +0000]
"GET http://116.0.22.245/prxjdg.cgi?en HTTP/1.0" 404 947 "-"
"Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.0; .NET CLR 1.0.3705)"

{ 1 comment }

I’m not an expert at OSX. I’ve used PCs since I was 11… starting with Windows 3.11 and soon after Windows 95. One thing I was frustrated with was that .rb files are automatically associated with XCode. And I tried to right click and select “Always Open with Textmate” but it never seemed to work. Today I got a little mad and went hunting online and found this page:  http://www.tech-recipes.com/rx/2573/os_x_how_to_change_default_application_to_open_file_type/ and it works

Here’s the short version:

  • Click on a .rb file
  • On your keyboard press cmd + I (thats an ‘I’ like interesting)
  • Under the “Open with” menu, select Textmate and click the “Change All” button

Awesome!

{ 0 comments }

In one of my earlier posts, I showed you how to reuse cucumber step definitions inside other step definitions. Today, I came across a simple “gotcha” that took me a few minutes to debug… so I think it’s something that you should know about if you plan on using that technique.

Here is the faulty code (assume all the reused step definitions exist and don’t contain any errors):

Given /^I am logged in with email "([^\"]*)" and password "([^\"]*)"$/ do |email, password|
  Given 'I go to the login page'
  And 'I fill in "email" with "#{email}"'
  And 'I fill in "password" with "#{password}"'
  And 'I press "Login"'
  Then 'I should see "Login successful"'
end

The funky thing was that it didn’t really raise an error. However, later in the code when I try to login, it wouldn’t do it and the page contains this error:

1 error prohibited this user session from being savedThere were problems with the following fields:Email does not exist

Can you see the error? The problem is that I’m trying to use #{} inside a single quoted string (i.e: ’string’ ) which takes everything inside it literally. If it were a double quoted string (i.e. “string”), it would evaluate whatever was inside the #{} and mix it in with the string.

So here’s what’s happening. When I tell it:

Given I am logged in with email "my@email.com" and password "secret"

It fills in the email field with “#{email}” instead of “my@email.com”.

There is a simple fix:

Given /^I am logged in with email "([^\"]*)" and password "([^\"]*)"$/ do |email, password|
  Given 'I go to the login page'
  And 'I fill in "email" with "' + email + '"'
  And 'I fill in "password" with "' + password + '"'
  And 'I press "Login"'
  Then 'I should see "Login successful"'
end

I don’t like it but it works. Also, a better way to write the above might be to not reuse the webrat step definitions and write it with webrat’s ruby methods like this:

Given /^I am logged in with email "([^\"]*)" and password "([^\"]*)"$/ do |email, password|
  visit login_path
  fill_in       "email",    :with => email
  fill_in       "password", :with => password
  click_button  "Login"
  Then 'I should see "Login successful"'
end

I’m not sure which one I prefer more. I’m leaning towards the plain English version even if it means manually joining strings using +. What are your thoughts?

{ 2 comments }

I just wanted to point out to you that I’ve been updating the Rails 3 page daily. There are some great new links & resources added over the past week… including a link to an interview in which Yehuda Katz mentions a new Queuing system that will be baked into Rails 3. I’m getting excited!

{ 0 comments }

via Bedazzle Your Bash Prompt with Git Info // RailsTips by John Nunemaker.

I came across the above rails tip by John Nunemaker today. It shows how you can show which git branch you’re on while in your bash terminal.

The code he provided didn’t exactly work for me (I’m on OSX) so I ended up changing things a little bit:

function parse_git_branch {
  git branch 2> /dev/null | sed -e '/^[^*]/d' -e 's/* \(.*\)/(\1)/'
}

GREEN="\[33[0;32m\]"
YELLOW="\[33[0;33m\]"
WHITE="\[33[0;0m\]"

PS1="$GREEN\$(date +%H:%M) \w$YELLOW \$(parse_git_branch)$WHITE\$ "

This produces a bash that looks like the screenshot below. As you’ve probably guessed, jetpack is the git repo/directory and authorization is the branch I’m currently on.

Git repo on authorization branch

{ 6 comments }

Yehuda Katz

What to Expect in Rails 3.0.

Yehuda is going to be speaking about what to expect in Rails 3 on May 22, 2009 at 10am (PST) / 1pm (EST). The webcast is hosted by O’Reilly and is free (like beer) but it does require registration.

I’m not sure if there is “limited seating” so register now.

PS: I will be attending & taking lots of notes so if you won’t be able to make it but have questions, leave them in the comments. I’ll pass them along to Yehuda.

{ 0 comments }