Archive for the 'Uncategorized' Category

nil.[] error when using Rails migrations

Thursday, August 2nd, 2007

I just had a little trouble with Rails migrations. I was trying to add a column to a database table in the migration using:

add_column :condos, :product_id, :int, :null => false, :limit => ’11′

The syntax seems ok at first glance but it resulted in the following error:

– add_column("condos", "product_id", "int")
rake aborted!
You have a nil object when you didn’t expect it!
You might have expected an instance of Array.
The error occurred while evaluating nil.[]
/usr/lib64/ruby/gems/1.8/gems/activerecord-1.15.3/lib/active_record/connection_adapters/abstract/schema_statements.rb:272:in `type_to_sql’
/usr/lib64/ruby/gems/1.8/gems/activerecord-1.15.3/lib/active_record/connection_adapters/abstract/schema_statements.rb:122:in `add_column’

The type_to_sql should have given it away to me but I overlooked it at first and spun my wheels trying to figure out what was wrong. As it turned out :int is not right and I need to use :integer instead.

The success of Webster's Classroom

Thursday, August 2nd, 2007

Over this past summer I’ve been working on a project for my wife Laura. She’s the technology teacher at school and needed an easy way for her teachers to create their own classroom webpage. Before Webster’s Classroom she had to manually create every teacher’s page and ftp it to a county server downtown. Needless to say, no one had websites.

Webster's Classroom 1.0

We created an easy way for teachers to do this by using Webster’s Classroom. Best of all, we’re offering it to teachers absolutely FREE. Laura got a warm reception from her peers when she demonstrated our software during the first few days of school. A number of teachers have already used our software to setup their own customized classroom webpage and appear enthusiastic about using it throughout the year. We have many plans for additional features in the next year. So far we are getting very positive feedback on the site and we are excited to add new features to the site. We will be aggressively marketing it at the software matures over the coming months and I’ll be sure to post updates every so often on it.

Safari and Firefox multipart form submission differences

Monday, July 30th, 2007

I just stumbled on a strange difference between submitting multiparts forms via Firefox and Safari. When a file isn’t selected and the form is submitted, Firefox sends the variable name with an empty string as the value. Safari doesn’t send the variable at all. This caused an unexpected problem in Rails when I was checking if the variable was an empty string or not. I honest would prefer to check if the variable is nil or not and if its not nil I’d know the file was sent. I checked for an empty string because Firefox sends the variable. Not my code has to also check if its nil and if not then check if the filename is not an empty string. Lame.

Censored yet again

Wednesday, October 18th, 2006

My last few posts were deleted at the request of my employer. It seems no matter what I write someone wants to censor me. I don’t think I’ll be updating this blog anymore as a result. Cheers

UPDATE: Screw my employer. I write what I please.

Firefox for Linux adware?

Monday, April 24th, 2006

I have recently noticed that Firefox would randomly go to different websites. For a while I thought it was my touchpad acting up and somehow taking text that I had copied and somehow pasting it to Firefox which would in turn search google and go to the first site that matched. The ads seemed to become more and more frequent until I decided to do something about it. I took a look at my .mozilla directory. Lots of stuff in there… I saw some strange things from Silverpop that looked like it was running JavaScripts from them. I deleted those lines but figured I didn’t want to wait until it happened again and then I just deleted the whole .mozilla directory. I have no doubt that I had adware which I installed somehow. It could have been an extension I installed or an exploit caused by JavaScript. I backed up my bookmarks and deleted the .mozilla directory. Right afterI did that I felt like I should have saved it and found out why I had this strangeness installed. After all my work to secure my system, it’s all been compromised by some stupid Firefox nonsense. I feel shafted. Any ideas?

JavaScript in IE

Tuesday, April 18th, 2006

After wrangling with this JavaScript code in IE which worked perfectly in Firefox (sound familiar?) I finally installed two things in my Windows virtual machine. First was a JS debugger and the other was a IE developer toolbar. The toolbar was pretty nifty and allowed me to examine the DOM objects that I was dynamically creating. What’s this? Why doesn’t IE see an ID and a name for this element? That’s because I capitalized them when I was adding them ‘

‘. Now, if I was starting from scratch I wouldn’t have never capitalized in the first place. I didn’t expect it to be a problem but apparently it is. Without it being lowercase, IE never finds the object when trying to access it. Solution: keep it all lowercase and definately use the JS debugger and IE developer toolbar when working with this browser.

File Uploading via AJAX using Rails Helpers

Tuesday, March 28th, 2006

I’ve come across an interesting situation when trying to write the Desko filesystem plugin. The issue is that I want an AJAX call to upload a file to Desko. The problem is that Javascript shouldn’t be allowed to access the local filesystem for security purposes. Apparently there is a hack around it (meaning there is a security risk with Javascript still?). I was trying to get others’ fixes working. One of them uses RJS templates which required me to install a gem for it. RJS from what I can see is a template that uses Javascript(rjs) instead of Ruby(rhtml). There is a nice helper function with it that does the AJAX file upload workaround automagically and I wanted to use it. RJS is supposed to be integrated into Rails 1.1. Lucky for me, Rails 1.1 was released today. I’m excited to get home to try it out and see if it can do what I want.

RadRails

Friday, March 3rd, 2006

Until today I’ve been coding Ruby programs in emacs. Since I just reinstalled, I don’t have any customizations for my emacs yet so I figured I’d explore some alternatives. I checked out RadRails since I had been meaning to for a while now. It’s an IDE written using the Eclipse RCP. It’s pretty slick and I’m planning on sticking with it for now. I already feel more productive.

Encrypting root and swap using dm-crypt with Luks

Thursday, February 23rd, 2006

I finally encrypted my hard drive using this article from the Gentoo wiki. It wasn’t 100% accurate and I’ll point out those discrepancies here. First off the instructions for setting up the swap during install weren’t at all accurate to the best of my knowledge. It was assuming you already had an install and wanted to encrypt your swap. This was useless and I ended up not even having a swap for the entire install and it went just fine.

Second, the genkernel-luks default kernel doesn’t work right with this. It leaves things out of the kernel and doesn’t build the initrd properly. I had to recompile the kernel and verify that everything needed was compiled in. Then I had to hand craft the initrd. The tutorial talks about a lib64 but you can just assume that it’s only lib when installing on an x86.

Third, and this was the biggest pain for me, when creating the initrd the tutorial suggests doing ‘ls -l /dev/mapper/’ to find out the major/minor numbers for the control node. Then they give an example. Using the Gentoo minimal LiveCD, my major/minor numbers for ‘/dev/mapper/control’ were different than the example. I figured since it was working on the LiveCD they are probably the right ones. Wrong. The example in the tutorial gave the right major/minor numbers and it took me a long time to diagnose the problem. I learned a lot about creating an initrd image and the initial linux boot process along the way though.

So as my reward for all this hard labor I now have the encryted root file system I alway wanted. Swap is encrypted with a new key each bootup. What fun!

I am not alone

Thursday, January 26th, 2006

I am definately not the only one who recognizes the problems with the new Web 2.0 concepts. David M Johnson has a post about how it’s about controlling your data. I completely agree and the web desktop app I am proposing will address those very issues. I hope to have a development environment up and running along with some code within the next couple weeks. There will be a link to the project from this site when I get it up and running.