Wednesday, January 28, 2009

Forms and Links

Tonight I was able to put some solid time into OutBlogger, users can now add watches to feeds they are interested in.

So I've gotten a decent handle on Rails by now but I still struggle in two main areas: Forms and Links in views. It's simply a matter of not knowing which tool to apply where (form_for, link_to, button_to, etc.). Rails has a number of helper methods and it seems like every example I look at implements them differently... Which leads to frustration and me trying a number of different things. I usually know WHAT I need to do (ex. tonight I needed to send a POST containing a new watch to the watches controller) but I struggle with HOW to do build inside a view.

Head colds suck.

Saturday, January 24, 2009

OutBlogger and TDD

My RSS reader is working in a fairly simple form. I've tried to engage in test driven development while creating OutBlogger.

Starting from scratch, I've tried following the mantra "write no code unless a test fails." This left me writing tests such as this one:
def test_create_duplicate_feed
   feed_a = => "")
   feed_b = => "")
   assert !
This test allowed me to write one line of code in the model:
validates_uniqueness_of :url
Needless to say it was a little slow and frustrating at the start. Since then I've adjusted the mantra and am now just coding the easy, boring stuff and using intermittent TDD for interesting stuff. I do keep away from generating generic scaffolds inside the project, as that creates tons of unnecessary code. This mix of quasi-TDD and avoiding the generate command has tidied up my code a great deal and made iterative development much easier.

Monday, January 19, 2009

Itest flag. Noted.

When running tests by hand from the command line be sure to include the "-Itest" flag. Without this flag the test_helper.rb file won't be loaded properly, your tests will not run.

Relevant RoR commit

Outblogger and Users

So Outblogger is taking the form of an RSS/Atom reader, initially.. This makes sense: the ability to read and track feeds is central to what I'm trying to accomplish.

The book I read and wrote about previously mentioned a plugin called restful_authentication, which provides a basic user model and authentication in a RESTful way. It's working out great for my simple application! The restful_authentication plugin is available here.

Sunday, January 18, 2009

Tim Bray Interview

I found an old interview with Tim Bray, Director of Web Technologies at Sun. He has some comments on how Sun may view the Ruby and Rails movement:

"Sun is a big company and I think that to a certain extent Rails probably is seen as falling into the LAMP basket" ... "My opinion is that we are vendors of computer systems and a lot of people are writing very cool code based on those kind of technologies, so we ought to be falling over ourselves to sell computers and to run them on, even though it's not Java."

Towards the end of the interview there are some interesting comments on static vs. dynamic typing, the Atom standard, and TDD.

Wednesday, January 14, 2009

Restful Design of Outblogger

So I've been playing around with my feed reader, outblogger, for the last couple days. Over Christmas vacation I re-thought the application restfully and have been slowly making those design changes. There's an amazing difference between a restful application on rails and a PB-designed state machine machine on rails. With the former I feel like the conductor of an orchestra; with the latter I feel like a person working the old telephone switchboards...

Sunday, January 4, 2009

A tip from a Tortise

How to call private/protected methods from tests:

Calling a private method is easy enough to do it when eeded but also
ugly enough to prevent you overdoing it:

obj.send :my_private_method, arg_foo, arg_bar

Also, if you define the method as static (self.method_name) you can
call it in exactly the same way:

ClassName.send :my_private_method, arg_foo, arg_bar

Friday, January 2, 2009

Mercurial in Netbeans Fix

In order to avoid an ugly bug in Netbeans 6.5, one which removed all rake functionality from the Netbeans IDE, I installed the latest build of Netbeans for Ruby (and RoR). Unfortunately, this install messed with my Mercurial settings and it took me around half an hour to track down the issue.

Tools->Options->Misc tab->Versioning tab->Mercurial
The Mercurial executable path wasn't imported correctly, Netbeans was unable to find hg.exe.

Its nice to have rake tasks...