NoobOnRails

Ruby on Rails tips, tricks and hints for the aspiring rails hero.



Tuesday, January 30, 2007

Microsoft Visual Studio goes red



Not the "his filled red with rage" kin fo red either. The Sapphire Steel Software chaps did it. Ruby in Steel is now available for public consumption and lots of money. Ruby in Steel is a professional full blown Ruby IDE integrated into Microsoft's Visual Studio. If you hop on the Ruby in Steel bandwagon now, you can pick it up for the limited time price of $199. It will normally run for $249. For the $$$ adverse, there is a version you can download that doesn't have all of the whiz-bang features but it may be good enough.

If you want to know what all you can do with it, check out the feature list. Woah, now that's a list.

Helpful Mac OS X tips


Now that I've joined a team of full on Railers who all develop on Macs, I've had to jump in to the Mac OS X environment with both feet. After just staring at my Macbook for about a good 30 minutes when I first got it, I quickly had to adapt my old windows habits and shortcuts to my new Mac environment. This is mostly inspired by a recent post at Juixe TechKnow about the Mac OS X F11 key. So here's my list, feel free to add on...

press F11 - is like "Show Desktop" in Windows. It moves all windows out of the way. Pressing it again brings the windows back.

press F12 - Shows you your widgets(proper name?). I still have the defaults on mine which are the Calculator, Weather, Clock and Calendar.

press F10 - Tiles the windows of whatever program you have open. For example, if you have 4 FireFox windows open because you detest tabs, pressing F10 will tile them for you.

press F9 - Tiles all of your non-minimized windows.

press Apple+Shift+(Number 4) - All together - Changes your cursor into a little target looking icon which you can click and drag to create a screenshot of the area you selected. The screenshot gets saved to your desktop with a name like "Picture 1.png". Awesome.

Terminal Tip - while in Terminal, you don't even have to fully type out your directory or file names. Just type the first few letters and hit tab and if that file is the only one with that name, it will fill it in for you. for example, if you're in the root of your rails app, my-awesome-computer:~/desktop/appz/rails4life and you type in 'scr' and then hit the tab key, you get script. Then type 'se' and hit tab and you get 'server'.

Textmate - Best text editor ever. My tip? Use it.

So those are the tips I've found handy so far. Anything else I should know about?

Labels: , ,

Sunday, January 28, 2007

Acts_as_taggable is no more!


We all knew it was bound to happen, but Evan Weaver made it official. Weaver has killed off acts_as_taggable. Not directly, but since no one is really doing much with the acts as taggable gem or plugin these days, they might as well be dead. But don't fret, Evan's has_many_polymorphs plugin will cure what ails you. He has up plenty of good examples of how to use his plugin on his site and even how to migrate your data and database structure from using acts_as_taggable to get them ready to use his plugin. I haven't used it yet, but it looks pretty solid.

Here's the plug-in page.

Friday, January 19, 2007

For the love of your Migrations, Reset your column info !


So a co-worker and I were hacking on migrations when one of them began to fail silently. It a migration we created to just add some data and not actually do anything structurally. The migration itself looked something like this...

class IMINURDBMIGRATINGURDATAZ <> def self.up
fruits.each do |f|
a = Fruits.find_by_type(f[0])
a.smelliness = f[1]
a.save!
end
end

def self.down
end

def self.fruits
[['apple', 'like a flower'],
['orange', 'like citrus heaven'],
['kiwi', 'like sweet tarts in syrup'],
['onion', 'like how you would imagine death would smell']]
end
end



So what the up is doing is basically finding each fruit by type and setting the smelliness for each one. Looks good right? We thought so too. We ran it and it didn't work. So we popped into console (ruby/script console) and tried the exact same code there, it works. Hmm, that's odd. We blow all the tables away and try it again. No bueno. 45 minutes of head scratching and "WTF!?!" later and with the help of our boss, we figure out that it's because we kept running all of the migrations in succession. Because we were doing so and that a separate, previous migration was adding the smelliness table, we couldn't write to the smelliness column yet because we weren't reloading the column information from the object itself.

So, we fixed it by adding

Fruit.reset_column_information

right above our iteration in the up method, like so...

class IMINURDBMIGRATINGURDATAZ <> Fruit.reset_column_information

def self.up
fruits.each do |f|
a = Fruits.find_by_type(f[0])
a.smelliness = f[1]
a.save!
end
end

def self.down
end

def self.fruits
[['apple', 'like a flower'],
['orange', 'like citrus heaven'],
['kiwi', 'like sweet tarts in syrup'],
['onion', 'like how you would imagine death would smell']]
end
end



I hope this saves someone else out there some time because it wasn't easy to find.

Labels: , ,