Go to content Go to menu

I’m tired of having my browser hijacked by window.alert(). Before the advent of tabbed browsing, I’m sure that taking over the application wasn’t that bad, but now that I have multiple web pages and applications open in different tabs it’s a different situation. I don’t see why my browser won’t let me do anything (I can’t even close it!) when some website wants to tell me something.

Is this feature listed for FF3? If not, it should be. Or maybe an extension could take care of this? Any takers?

Here’s a little one that got me in the past. When you’re writing a method of a model, you have to be careful about how you set attributes.

Let’s say for example that you have a model Country, with attributes population, area, and government. When you want to use this property in a method, you can say:

Country
  def population_density
    area / population
  end
end

And this will work just fine. So, it seems like you can use the area and population in your code when you need to deal with these attributes.

Watch Out!

Look out that you don’t do this in the method:

Country
  def plague
    government = 'anarchy'
    population = 0
    save
  end
end

The problem is that population = 0 will only set a local variable to 0, and not your population attribute. Instead, you have to use self.population = 0. So, your #plague method would look like this:

def plague
  self.government = 'anarchy'
  self.population = 0
  save
end

Disclaimer:

Yes, I know, #plague would really look like this:

def plague
  update_attributes :government => 'anargy', :population => 0
end

I used the example above to demonstrate the concept.

They work together out of the box.

SASS
Styler

Let this quote explain:

In Fortran, all variables starting with the letters I, J, K, L, M and N are integers... (This is the source of the long tradition of using "i", "j", "k" etc as the loop indexes of "for loops" in many programming languages -- few of which have implicit typing).

Wikipedia - Sigil (computer programming)

I guess you learn something new everyday.

I just found out that you can run a single test in TextMate with Apple+Shift+R when you’re editing a test in Ruby on Rails mode. No more scrolling in my test window!