June 22nd, 2007

Google Finds Sites in a new way

Posted by Jeremy2 in General Musings / Rants

It seems that Google is now looking up site records themselves or something, because I’ve created a couple of sites lately, and they pull up within the Google index. They do this despite the fact that I have not submitted them to any search engines and have not linked to them from any other site. I’ve looked up the same sites in Yahoo! and MSN, and they are not there at all. I’m starting to think that Google is lowering the bar in who gets indexed, but I am sure that they are keeping it high for those who wish to get a top ranking.

–Update:–

It seems that if Google finds a piece of text (not necessarily a link) that has your URL, then it will index the site. That’s the only conclusion that I can come up with so far, as I have found text with my URLs in them on Google.

June 16th, 2007

Comparison Problem in Ruby

Posted by Jeremy2 in General Musings / Rants

For the past few days I have immersed myself in Ruby on Rails, and for the most part I have been loving every minute of it. However, there was a problem I was having in my code that was driving me nuts. I think I spent nearly four hours on it until I figured out what the problem was, exactly. I had the following bit of code in my model:


def add_attribute_group (the_id)
current_attribute_groups.each do |v|
found = v.attribute_group_id == the_id
break if found
end
if !found && grp = AttributeGroup.find(the_id)
iag = ItemAttributeGroup.new({:attribute_group => grp, :item => self})
current_attribute_groups < < iag
end
end

Rails defines the foreign key ID (in this case attribute_group_id) as a string rather than a number, and so if you try to do a comparison to a number, this will not work! I’ve been spoiled by PHP which treats 3 and “3″ as the same thing. For instance:


$a = '3';
$b = 3;
$a == $b ; //This will return true

However it appears in Ruby:

a = 3
b = '3'
a == b #This will return false

I had to amend this line:

found = v.attribute_group_id == the_id

… to read like this:

found = v.attribute_group_id.to_i == the_id