NoobOnRails

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



Thursday, February 23, 2006

New del-icio-us links


Just added my del.icio.us list of Ruby on Rails blogs I've come across over to the right. I've set the display to 100 so have fun going through'em.

Friday, February 10, 2006

New acts_as_taggable on it's way from the Heinmiester


Is there a newer version of the acts_as_taggable plugging on the way from the loud thinker himself?

While checking out Chad Fowler's Rails Recipes pre-purchased (still haven't purchased it yet but I'm close), I noticed there were excerpts of certain sections. One of the available excerpts being the Tagging recipe. I decided to take a look hoping to see if I needed to update my acts as taggable short I wrote up a few months ago. So I'm looking through it and read...

David Heinemeier Hansson’s acts_as_taggable plugin...


followed by

• Rails 1.1 or above. The acts_as_taggable( ) plugin relies on the polymorphic
associations feature of ActiveRecord, which was added
after Rails 1.0.


Woah woah, wtf!?!?! Where can I get some of this lovin! The doc itself mentions it's as easy as

ruby script/plugin install acts_as_taggable

and you're off and running. You will most likely have to be working with edge rails due to the polymorphism of this plug in but cot dang does if it doesn't give your warm fuzzies. There really isn't any documentation for it yet, not even in the actual plugin itself but it basically looks like you need to create a taggings table and tag your taggable model with a acts_as_taggable. There's more information on it in Chad Fowler's book which I'm about to pick up...really...I promise.

I'll also write more about it when I get a chance to tinker with it.

It came from the mailing list...


Here are a few tibdits gleaded from my trying to read every post on the mialing list every day for the past few weeks (i'm way behind)...

Need to do some table striping but don't want to cramp your hand doing so?
Kevin posts about the Cycle helper...snippet

> You can also use the 'cycle' helper to do the table striping.
>
> Do something like this...
>
> ">

'cycle' is a predefined helper for doing table striping.

See the api docs for 'cycle'



How about a little refactoring? Say you have some code that iterates through all items in a given collection to save them all...instead of doing it the hard way, cut your work day in half with this tip...

> > On the other hand, you probably also need to make sure the records are
> > valid, so..
> > good_to_go = true
> > @collection.each do |record|
> > good_to_go = false unless record.save
> > end
> > flash[:notice] = "All records saved. Lunch break!" if good_to_go
> > etc, etc, etc.
>
> You could also do it like this:
>
> good_to_go = @collection.all? { |r| r.save }

Thursday, February 09, 2006

FYI re: Rails Migrations


If you're looking into setting up your migrations but nothing happens when you try

ruby script\generate migration MyAwsomeMigrationRocks

just go ahead and try a

rake migrate

This may give you a more helpful error since it the generate migrate may not say anything if it fails. When you do the rake migrate, you may get a rake aborted, could not find RubyGem TheGemToRuleThemAll or something similar. Then you go fix that error, and then try to re-generate your migration and it should work, telling you what files were created where.

booyah.

Ruby for Rails book hits beta



From David A. Black through Manning Publications comes Ruby for Rails which sounds like it would be a good way to actually understanding how to better use Ruby for use with Rails and how Rails itself uses Ruby. It is still "in progrss" but while it isn't finished (only the first chapter is available), you can begin reading it by buying an MEAP subscription for $22.50. Here's what the upcoming chapaters are looking like:

Chapter 1: How Ruby works
Chapter 2: How Rails works
Chapter 3: The Ruby/Rails conjunction
Chapter 4: Objects and variables
Chapter 5: Organizing objects with classes
Chapter 6: Modules
Chapter 7: The default object (self) and scope
Chapter 8: Control flow
Chapter 9: Built-in essentials
Chapter 10: Scalar objects
Chapter 11: Collections and container objects
Chapter 12: Regular expressions
Chapter 13: Ruby Dynamics
Chapter 14: Expanding the domain of domain modeling
Chapter 15: Adding programmatic value to entity models
Chapter 16: Controller and view strategies
Chapter 17: Exploring the Rails source code
Chapter 18: Conclusion

If only this was out when I was a noob, I might have actually been able to understand the Rails api docs. Eh...learning the hard way it fun too.

Tuesday, February 07, 2006

For you the reader...


Since I think more people than just myself read this blog, where would you like to see it go? Do you want more articles like my acts as taagable articles (one and two)? and if so, what should I cover? I have some articles I'm already working on but I just wanted to see if the people wanted to see something in particular.

VMServer


Since I'm not cool enough to get into Mac world yet (that's right...yet), VMware releasing their VMserver for free recently was pretty cool for me so I figured I'd send out a little blurb about it. I was able to download it, install it and get Ubuntu up and running on my Windows box within 15-20 minutes. Now I have a *nix environment to build into a mock server to due some test staging. As fun as integrating Rails into IIS sounds, I think I like this way better.

Happenings in the Rails world


Being as into Rails as we all are, I consider it my duty to inform you of the upcoming Rails evetns.




First up is Canada on Rails, going down April 13th (Thrus) and 14th (Fri) in Vancover Canada. I don't believe they're sold out yet so feel free to pick up your $250.00 (for now, will go up to $300) ticket online to make sure you get to partake in the festivities. Who else is going? Beats the hell outta me, but I don't know the speaker list...

David Hansson, creator of Ruby on Rails
Thomas Fuchs, creator of script.aculo.us
Dave Astels, published author on Test Driven Development
David Black, creator of SCANF.rb, RCRArchive
Joe O'Brien, developer with ThoughtWorks
James Adam, creator of Rails-Engines
Steven Baker, creator of RSPEC
Michael Buffington, cofounder of Price.com, co-architect of MeasureMap.com
Robby Russell, founder of Planet Argon
Geoffrey Grosenbach, host of Ruby on Rails Podcast
Kyle Shank, lead developer of RadRails and Rubish

Jeremy Voorhis, lead architect at Planet Argon
Alex Bunardzic, founder of Jooto
Sebastian Kanthak, creator of FileColumn plugin
Amy Hoy, future author of a "Right-Brained Guide" to Ruby on Rails

Talk about a strong lineup. You know you want to go.

If you're an asipiring Rails groupie and are already looking for the Rails event after Canada on Rails, look no further than the first official Rails conference creatively dubbed RailsConf! RailsConf 2006 will begin on June 22nd and run through the 25th in the ever windy (or so I've heard) city of Chicago Illinois. This sucker is selling fast so register ASAP to maintain your sanity and your Rails credibility. IF you're going to RailsConf, I would also recommend you look into attending the Pragmatic Studio's "The Rails Guidebook" event which sounds more or less like a crash crouse intro to Ruby and Ruby on Rails. They're not charging admission but they are taking donations. Feed your brain and your spirit at the same time, it's two for one people. See the value! The offical list of speakers aren't out yet (the keynotes are) but expect everyone who's anyone to be there......RailsConf!

Now those events are good an all but if you're like me (i.e. broke, hence the use of blogger) those events might be a bit out of reach financially. So what does a Rails-hero-to-be do in the meantime? Well, might not pick up/download one of the latest Rails books to hit the streets.



The one that gets my hear beating the fastest is Chad Fowler's Rails Recipes. It's in beta mode right now with only a percentage (like 30%-40% I believe) finished but you can still buy it now and watch it grow. There is surely going to be a lot of good Rails content and code in that one. I plan on picking it up shortly (*cough*freereviewcopy*cough*) and when I do, I'll let you all know about it.

Never the ones to let a good idea get away, the O’Reilly-ers have released their own form of "beta books" with their Rough Cuts series.



First up is Ruby on Rails: Up and Running: Rough Cuts Version by way of Bruce A. Tate and Rails tutorial pioneer Curt Hibbs. I say tutorial pioneer because most of the articles he wrote on Rails (I say most becaise it seems like it, in all reality it's probably two or three) ended up on Slashdot which I saw and began my whole interest in Ruby and Rails. He also happens ot be the reason why I changed my IRC nick from curtis3000 to noobieonrails.



There is also Ruby Cookbook: Rough Cuts Version coming to you from the hands of Leonard Richardson and Lucas Carlson.

So even if you don't plan on making the conferences, pick up a book or two. Support the community and expand your knowledge since you know the IRC channel (#rubyonrails) will be dead silent anyway.

Monday, February 06, 2006

For the love of god...


I'll update within the next day or two. I've been trying to catch up on all the rails mailing list emails that I missed during the holidays. I have not been able to get under 300 new e-mails in my inbox...ugh. I'll post some tips I caught through the mailing list though. If only I never had to sleep....