Archive for the ‘Uncategorized’ Category

The Rails 2.3.x Release Process

Tuesday, May 25th, 2010

In my When Rails 3 is due post, I note all the dates where the Rails versions have been released. Since it’s posting, have updated my prediction for a release candidate of Rails 3 to be RailsConf. It all makes logical sense that at Rails’ biggest event they would do this. But can we, as a community, get it polished before then? I hope so!

This post is not about Rails 3, however.

It’s about the release process of the 2.3.x versions of Rails, specifically the process behind the latest four releases for this particular branch. The latest version, as of this writing is 2.3.7 and is unusable. 2.3.8-pre1 is out, and I suggest trying your applications on that and seeing if anything breaks. As a recap: 2.3.5 was released in November of last year, 2.3.6 this weekend just gone,2.3.7 yesterday and 2.3.8.pre1 shortly thereafter.

Let’s begin with what pre-releases are for: they are for people to test them to ensure that the final release is “smooth”. If you want to contribute to Rails: spend some time from your week ensuring your application runs on the latest version of Rails and report any problems. It’s not hard to create a branch and do this. If you are one to ignore pre-releases, then you are not one who should be complaining when things break in the final version of your application. In almost every case, your application will work. You may get the “off-suit draw” and something breaks. Report your problem.

A problem occurs when patch releases are made without any pre-releases at all.

2.3.6 was released without a pre-release. Whilst this is may be perceived as a catastrofuck for some people, it was a long time due. The prior release, 2.3.5, was released almost dead-on six months ago. Six months between releases, in the Rails world, is a long time. Things have been progressing rapidly, and a lot of people will benefit from the changes introduced by these new versions, including support for rack and thin 1.1.0. Yes, now you’ll be able to run your Rails app by using Thin.

However, 2.3.6 broke HAML which Nathan Weizenbaum tweeted about. He later said he had worked around it and contributed back to Rails in these three commits. Jeremy Kemper (bitsweat) then thought that there should be a 2.3.7 release.

Unfortunately this first commit broke Rails view helpers — such as form_tag — for those who didn’t have the rails-xss plugin installed. Jeremy missed this, and I spoke with him earlier and from what I could determine he missed the bug because he had rails-xss installed. When people upgraded to 2.3.7, there was an outcry started. A few people announced this issue, and therefore 2.3.7 was broken.

Whilst Rails is pretty exceptionally tested, it’s not 100%-watertight. Would this have happened if there was a pre-release? Yes and no.

On the yes side of the fence, people generally view pre-releases as “potentially unstable” and won’t upgrade their application, therefore they won’t upgrade. I implore you: upgrade your application locally to these new versions and run your tests. You do have tests, don’t you? Then if it breaks: report your problem. Patches very, very, very welcome.

On the no side, there is that handful of people who do test new releases when they come out. Therefore, this issue may have been raised if there was a pre-release. We can’t know for sure.

2.3.8 was released a couple of hours ago and Jeremy has apologised for the rushed releases and promised to follow the “same methodical drumbeat” for every release, regardless if it’s major, minor or patch. He is an absolute legend for working on this issue pretty consistently since the weekend and for getting a push out as quickly as possible.

With this release, now we’ve got an up-to-date stable 2.3.

Ladies and gentlemen, upgrade your apps!

The Present

Saturday, May 22nd, 2010

About 6 months ago, Dr Nic and I were in the local-to-work bookstore for a reason I can’t recall. What do I recall though is the good Doctor ripping a book off the shelves and saying “You’re buying this book. Then you’re going to read it.”. This book was “How to Win Friends and Influence People” and it is in my (and millions of other’s) opinion(s) one of the greatest books ever written. It was written by Dale Carnegie in the 1930s and the wisdom in the words still holds true to this day. The foundations of human interaction has not changed much since those days, and it should not. I read the book, and it changed my perception of human interaction. I’m currently in the process of reading it again.

When I was in Scotland, I think on the Saturday before I left, I did to Sam what the Doctor did to me: pulled the same book off the shelf and said “You’re buying this book. Then you’re going to read it.” Sam whinged about paying for a book, so I paid for him. Then we took it home and it sat on the bookshelf in my temporary room for the next couple of days.

On the Monday, Sam had to take care of a couple of things for his new job and left me to my own devices. I took the book, a (“borrowed”) pen and my camera and went around town taking photographs. When my fingers got too numb from the cold, I stopped in at Costa for a hot chocolate and decided to write in the cover of the book. I’ve decided to post it here too because I feel some parts could apply to a greater “audience”. Here’s what I (hand)wrote:

[page 1]
To Sam,
Be decisive!
Smile!
Enjoy life & friends

Please read this cover to cover. It is not intended as a slight on your awesome personality, but rather intended to suggest more ways you can be [much more] awesome. After reading it, you may realise you have done “the wrong thing”. This is not the case, usually. We all do “the wrong thing” without realising it, and after reading this I often find myself thinking of how to be more patient and courteous to those around me, defusing otherwise emotional battles with people.

I have greatly enjoyed my time in Scotland with you and your family. Such generosity is rare and absolutely priceless in today’s world. If any of you wish to visit Down Under, I will do anything in my power to help you enjoy it.

[Page 2]
“He who can do this, has the whole world with him.”

Process what other people say before formulating a reply, and never interrupt them. Think of how you’d feel if the tables were turned.

[Page 3] I trust by now you are already bored of my scrawl. I would just like to say thanks again.
And again.
And again.

We all have the potential to be great/fantastic/awesome, so why not? Why not try improving somebody else’s day? Give them a compliment (hint: girls like compliments on what they are wearing. A wolf whistle is not a compliment!). Perhaps if you improve their day, it may improve your day, or even your life. Take advice. Embrace the world’s knowledge. Use it to your and everyone around you’s advantage. This includes your parents who quite obviously love you very much. Just remember what I said.

[Page 4]
Your parents have been around for twice as long as you have and have a great deal of knowledge. You may find, like I did, that co-operating with them is much easier than arguing. They only have your best interests in mind. They are great, but also as mortal as the rest of us. They will not be around forever. Enjoy as much time as you can with these fabulous people before you are unable to!

  1. Be kind (aka, keep going)
  2. What can you give others
  3. Take advice and use it!
  4. Read this book!

So long, Sam.

After I finished writing it, I put my spare travel money card in the middle and then snuck it into Sam’s bookshelf. When I left for home, I told him where I left it. He’s read it already cover to cover and appreciated my “foreword” and the book itself.

I really enjoyed Scotland and I wish Sam (and his family) all the best.

Recruiters: Know Thy Recruitees

Friday, May 21st, 2010

I suppose I’m well-known (at least in the Australian community) on my stance on bad recruiters. To me, their job is to perform the most minimalistic effort possible to get people for other companies and in doing so, they line their pockets with a nice pay packet. I even wrote what I look for in a job posting. It’s not difficult to “bait the line”. Spend that little bit of effort.

Recruiting sounds like quite the fantastic job and I’m sure that if I wasn’t teaching/coding at GetUp or writing a book, I would be “farming” people and then getting them hired at companies looking for developers and getting a nice pay packet from these companies from providing them with valuable people. In theory, anyway. I really feel there is a nice market here. It would be a bridge between those looking for Ruby on Rails training and those looking for experienced people.

I honestly appreciate those companies that have gone out of their way to contact me personally with job advertisements or offers. These companies know that if they want the best talent, that they’re not going to get it through some recruitment firm. The company knows what they are looking for, and therefore will (or at least, should) be actively involved enough in the community to know who’s available when. Sometimes I have not been able to consider them because I have been employed at the time, and others would have caused large changes, such as moving to another continent! When I announced I left Mocra, I had a lot of people contact me directly for job offers. I’m sure that if, today, I was to announce that I’m leaving GetUp (clarification: I’m not. At least not in the next month.), these same people and perhaps more would contact me with further work. Being in demand is a great feeling. I haven’t had to stress about job security because I know that if one job doesn’t work out, there’s always more.

You’re probably thinking I’m not very loyal. I am, but there are certain conditions that apply. For instance, you cannot buy my loyalty. If your job sucks, then I’m not going to enjoy myself doing it and will probably be looking for a way out. Give me something to do that I enjoy along with enough money for me to be able to pay the rent and enjoy my chosen lifestyle, and that’s how you can have my loyalty. Mocra kind of did this (I hear the situation has improved). GetUp does this.

So why don’t recruiters bait their lines when they go fishing for new people? Take this email I received on the 18th of May from a recruiter from an American recruiting company:

Hi Ryan, I’m recruiting for [list of big companies], and others. I ran across some of your Open Source work and wondered if you would be interested in chatting about a new opportunity. Having published open source code is a big plus for all of these companies! If you’re interested in discussing, please let me know.

Where’s the bait? What in this email is supposed to make me want to drop absolutely everything I’m doing now, start hyperventilating and type a response to this email? It’s sadly absent. I sent a reply anyway (typical nerd, desperate for more human interaction).

Yes I’m interested in discussing this with you, always good to talk to people who know what’s out there. When would you like to talk?

I say I’m interested (just window shopping for now) and ask when would be an appropriate time for them to speak to me. Business 101: cater to the other person. Think of what you can do to benefit them and then go about doing it.

So by now you may have realised that the 18th of May was 3 days ago. Which is ancient in email world. It had scrolled right to the precipice of my inbox and last night I saw it sitting there, mixed in with all the lighthouse notifications. They hadn’t replied in those 3 days. Maybe they sent it out to a lot of people and were busy. Whatever the reason, I decided to write again:

Hi [name], I’m still interested in discussing this with you. I am disappointed that you have not yet gotten back to me. Hope to hear from you soon, Ryan Bigg

And within 4 hours of my reply, they wrote back:

My apologies for not getting back to you. Are you interested in relocating out to Silicon Valley, or for a telecommuting opportunity?

I sleep with my iPhone in my bed running the Sleep Cycle app. I’m a stats fanatic. This morning I slept well. But I digress. Because my iPhone is so accessible and my computer is all the way on the other side of the room (about 1m from the end of my bed), I read my emails on my phone. The email that they wrote fit all on one “screen”. Again. No bait. Oh, “Silicon Valley” is supposed to be bait? Nah uh. I leapt (well, more of a roll) out of bed and almost tore open my macbook lid. I am in the mood for writing. Can you tell? So I wrote them back the kind of sized reply which I think is reasonable.

Hi there,

I am going to need more information before I can give a solid reply on that. Here’s some thing’s I am interested in about finding out about a job before making any decisions:

* The name of the company interested in hiring me. Unless [their company] is going to hire me to work for them directly, this is not you. It could be one of the companies you are doing the recruiting for, in which case I scouts-honor-cross-my-heart-and-hope-to-die promise you I won’t give away the name.

* What kind of work I would be required to do (For example, I am more keen on teaching people who are new to Ruby on Rails more than doing the coding myself. The open source work I have done is because it was something I was interested in at the time and I never intend for them to become successful viable products. Anyone who does open source and hopes for this to happen is, in my opinion, crazy.)

* The language I would be required to program in. I am proficient in Ruby on Rails (and therefore, by extension, just Ruby itself) but I am willing to learn other languages. If I had to learn another language would I be provided with on the job training?

* Are there any other skills require to perform this task? For example, at my current job (a contract that expires next month, fyi) I simply do not just teach Ruby. This of course means that I have to have the ability to work closely and patiently with other people on a project in order to meet deadlines. Then there’s the database work which involves data integrity, really fast database inserting and so on. Then there’s the “magnum opus” of the system which is getting that data from the database and into 500,000 emails which are to be sent out in under an hour. All of which I feel I’m very capable of doing.

* If I were to relocate to the Silcon Valley, would the company I relocated for cover my all my relocation costs, part of them, or none of them?

And of course the final point which anyone would be stupid not to ask:

* The fancy word is “remuneration package”. I’d like to call this “The number that determines what can I afford to eat, do and play”. I am of course talking about a salary. Would I be paid a competitive salary, or would I be on enough to afford half a packet of ramen noodles for dinner each night and maybe the flavour packet if I was feeling really hungry? If you are concerned that you cannot answer this question clearly, given that “competitive” means very little in this context, I am currently on around [pay]. Can you do that, or, preferably, better?

Looking forward to hear back from you once more,
Ryan Bigg

All of this information should have been provided as the bait from the original email. Now I am slightly annoyed that I have had to spend time helping them do their job correctly.

About an hour later, they replied with an email that answered my questions to the best of their ability. A nice big (seriously) non-sarcastic bravo! this is the kind of effort I’m talking about!

Hey Ryan, good questions! I’ll try to answer them all.

I mentioned the name of some of the companies in my first email. I am currently working with: [big companies]. I’m working with a few other companies as well but the ones mentioned are hiring the most. I look for the same thing for of these companies: Strong OO Development skills and a genuine interest in technology.

What you would be doing depends on the company and position. My approach here is to get you in touch with company and the engineering teams directly. That way you can discuss your interests and their requirements without a non-technical recruiter (me) getting in the way! ;). Strong OO development skills, strong interest in technology, ability to write “elegant” code that scales. These are the same requirements I have from most of my clients. In the case of [big company] for example, what you would actually be working on is not pre-determined but will be figured out during the interview process.

The languages vary. I will say that in the companies I’ve mentioned, none of the positions state Ruby or RoR as a requirement. C++/Python would be the most common combination in terms of requirements. Javascript is also pervasive throughout all of these companies. Most of these companies want people who can adapt quickly to new languages.

Knowledge or understanding of what makes code expensive (in terms of resources) and how to make applications scale is the single most important additional skill.

Relocation expenses. This again depends. This is part of what we would help to negotiate for you. In most cases, some sort of relocation packing would be included.

Compensation. Yes, if you were made an offer by one of these companies, I would expect it to exceed [rate] USD. Again, this will depend on your interview. Salary negotiations are something we can assist with as well. Average salary for a software engineer with 5+ years of experience is between $90,000 and $130,000 USD per year.

The next thing I would need is your CV/Resume. You’re[sic] github profile looks great! Once I review your resume I can give you more specific info on what companies and positions I think would be best.

Now we’re talking.

When I was initially contacted to write this book, this is the email they sent me:

I am writing you as an [position] with [company]. We are currently looking for a writer to [contribute to] our book on Rails 3. I came across your blog and thought you might be a good fit.

[redacted awesome things that may give away too much information]

Would you have any interest in joining this project? Please let me know. I look forward to hearing back from you, and would be happy to speak with you further about the book.

Bam! Straight to the point! I just about damn near well bounced off the walls when I read this email the first time. I still get giddy now reading it. We played email ping pong for about 5 volleys with the slowest turnaround being about 12 hours (because, occasionally, I sleep) This is the kind of recruitment I want to see more of! Be proactive and entice the people you want to hire. Bait the line.

Recruiters: know thine recruitees. When you go looking for new hires, give them a reason to leap out of bed and feverishly reply to your email. Just FYI: if I receive another email of this first email’s “standard” again, I’m not going to feel like replying as quickly as I did when I read the book email. If you’re not going to spend the time to write something detailed, then I am not going to spend the effort to write something back.

Do your job, and do it well or go away.

Do It Again

Wednesday, May 19th, 2010

Today was utter crap.

It wasn’t crap when I woke up. It was just another day. What woke me up at the semi-pleasant hour of 5am was my publisher calling. We had scheduled a call for 6 but I think he may have suffered from an “off-by-one” error. People make mistakes and I silently forgave him for this and talked business for 21 minutes. We’re making fantastic progress. I really felt good after this morning’s conversation.

Then I spent the next 3 and a half hours before work exhausting all my news sites and chatting with Sam Elliot (lenary) for an hour about a multitude of things. Hyper Numbers came up. I wrote them and posted it on Reddit and they replied later on in the day. I do see their point and I wish them well. Shame about the “code bukkake” though.

Then I went to work on my boss’s boss’s bike (loaned to me last Friday) and ding’d my bell at a couple of pedestrians and had the usual “not looking where I’m going so I’m just going to walk straight towards your bike in the hope that you swerve and miss me” occasions. This is what happens when you ride on footpaths. Oh, I should ride on the road? Have you seen Sydney peak hour? I value my life.

The first half of work, usually called “morning”, was good. We finished a feature yesterday and begun working on a new one, refunding donations, today. New features are always good to get rolling. The idea was to have the full refund done by the end of the day. What we’re currently working on is called “v3″ or “version 3″ or, if you’re keen on the buzzwords, “MVP” for “Minimal viable product”. What this acronym and term means varies from person to person, day to day and even weather condition to weather condition. It effectively means the application needs to be “good enough” for us to run an election campaign on. I won’t bore you with the technical details and only mention that it’s been in planning as early as January this year. With the election not yet having a set date (there’s rumours which boss^2 likes parading about), it’s hard to know when we’re going to have to release this thing. For as long as I’ve worked there, it’s been “before the election”.

Last week we were given a deadline. A specific time at the end of June. Right, that’s still a while off, right?

Boss^2 looks panicky.

“Are we going to get this done by that date?”

“How long do you think this will take?”

“What can we cut out of this to make it by then?”

All questions he asks. As a developer, I can say “that’s going to take “.

Boss^2 takes it as gospel. It has to be done by that date. Otherwise, disaster. The world is exploding. Next he knows, Tony Abbott will be PM.

Boss^1 acknowledges there is a deadline and also acknowledges that our estimates are… estimates, and that things can go wrong and things can get delayed and we can make up the time later on by developing it smarter (by writing tests).

I like Boss^1.

But Boss^2 is a realist. He feels that if this project doesn’t get off the ground that he may have to scrap it. Yes, this project that I’ve worked so diligently on for the past 3 months will be scrapped in favour of their old, kludged-together (but functional, kinda like my old VL Commodore) PHP system. Yeah.

So this afternoon we had an hour long meeting. An hour of time that could, in my opinion, have been better spent developing. We knew what needed to be done. We knew there was a deadline. All information conveyed in that meeting could have been done through an email exchange or, Hell, on Google Wave. I took notes. Especially of Boss^2′s lines. Such as “let’s assume we have design” and “let’s just park that issue”. Another golden one from this morning “I want you to work on that operationally”. Speak. Clearly. Please.

The other non-developer in the meeting, a senior campaigner, wore what I’ll refer to as his “sadface” throughout the meeting. I don’t like seeing people in that state. They want this new system, and we are working bloody hard to develop it.

As for the first line: We cannot must not assume we have anything at the moment. What if our designer is unavailable?

At the end of the meeting (at 5:15pm) I was drained. Did I mention I woke up at 5am? That probably didn’t help things. So I packed my things and headed home, it was the end of my day. I wheeled out the bike and took it down the elevator. Then I rode down Foveaux Street and waited at the lights to cross to go past Central. I hopped the traffic island on my bike and the back tyre blew. I checked it and it was a clean tear. I hadn’t bought a spare. Hindsight’s a bitch.

That was it. I’d had enough. I put the bike up against one of the columns and threw down my helmet and put both hands on the column and bowed my head for a couple of seconds. What a crap day. I phoned Francois (one of the ex-PHP coder’s who’s coming along well!) and thankfully he was still in the office. Took the bike back up Foveaux street (it’s a hill) to the office and left it in the “foyer” and took the stairs down to ground.

Then I caught a cab from the taxi “station” nearby, only to realise peak hour traffic is crap. You’d think with me walking alongside a main road just about every night for the past couple of months I’d know this. I got the driver to drop me off near Broadway supermarket. There they have a butcher that sells a “New York” steak. It’s the perfect size. I bought one and some potatoes, and now if you excuse me I’m going to go make the best fucking steak ever, eat it, and then just sit and think for some time. Think that, if I could do this day again with the knowledge I have now, what would I do differently? How can I make tomorrow better? And then just not think at all.

tl;dr: Book is going awesome. This week: work has sucked. Boss^2 is great source of buzzwords. My bike back tyre blew. I’m eating awesome steak to recuperate.

Railsbridge Bugmash

Saturday, May 15th, 2010

About a month ago I posted that not enough people are helping with Rails. If you’re keen to get into it, come jump on irc.freenode.net #railsbridge where the May Bugmash is underway. I’ll be around for the next couple of hours until I head to bed and all of tomorrow helping people out with issues. Come jump in!

Rails 3 Book: Staying Focussed

Monday, May 10th, 2010

Sometimes I have difficulty focussing on tasks and getting things done. I think that this is part of being human. There are some times where I will concentrate on a task so fiercely that I will ignore other things, such as that bad smell coming from the laundry basket in the back corner of my room. Then there are the times where I’m as apathetic to the task as a teenager to homework. I’ve been asked by a couple of people how I stay so focussed.

What’s my secret?

I break everything down into tiny chunks so my tiny brain can understand that, in order for there to be “happy happy joy joy fun time” this one little task needs to be done. In the process of writing, I’ve broken the book down into individual stories, just as a real app would be broken down. Each chapter can (and so far, all of them do) contain many stories. So far the average is 4, but with only two “storied” chapters written, this is an unfair average. The purpose for breaking it down into stories is two fold:

  1. As mentioned before, it demonstrates to the reader how a real application would be developed using BDD. Story by story.
  2. It “forces” the user to concentrate on just getting one “puzzle piece” done at a time

There’s also the top-secret 3rd “fold”: It helps me focus when I’m writing. If I know that there’s writing to be done (and boy (and girl), there’s writing to be done!) and I’m going “groan more writing!” I have the willpower to convince myself that if I can write a well-done story tonight it is one more story closer to completion than if I had not. That is enough to convince me that I should probably do some writing. I don’t have to write the WHOLE chapter in this one sitting. Just this one story. Then I can take a break and give it a skim-through to see if there’s any glaring omissions and fix them. Then I may even be eager enough after that to take another break, perhaps to go to the toilet or grab some food or do that washing that’s creating that God-awful smell. Anything that let’s me just think about what I’m doing for a moment, that’s a good thing. That’s one less distraction that I’m going to have when I enter the zone. I’m not going to think “I should eat”, because I already have. Deal with the distractions, then get on with it.

With this “technique” applied three weekends ago (a long weekend in Aussie-land) I managed to write nearly 16,000 words. Two weekends ago was my brother’s birthday, which was fantastic to see him and the rest of the family again. Nothing got done that weekend besides awesome catch up. Then this weekend, I wrote another 14,000 words. Between these periods I’ve been doing some self-editing and editing based on the suggestion of Others Who Cannot Be Named. This has left the total word count at 29,101 as of tonight.

Tomorrow night is the Ruby on Rails Sydney meetup which I’ll be at so there’ll be no writing done then, but it’s extremely likely that I’ll be at the magical 30,000 word mark come headdown (the time when my head hits my pillow) on Wednesday. And then beyond that. Eventually though, there will come a time where I will get to release this to you guys. That’s when I feel I won’t be writing as much, just fixing up what’s already been written. We’ll see. Perhaps I’ll feel ultra-motivated and get to that mystical target I’ve set myself of 20,000 words in a weekend. It’s a nice sounding number.

So in order to be ultra-focussed I deal with all possible distractions before starting tasks. I’m finding this is an effective way of being able to stay focussed for long periods of time, and I’m curious if this works for you too. I know other people use techniques like timeboxing and Pomodoro.

What works for you?

Listen to us

Friday, May 7th, 2010

From my time helping out in the #rubyonrails channel on Freenode, I have come across some awesome people whom I probably would have never met. Being able to talk with them is the major reason why I still hang out in there. Then there’s the coming and going of the people wishing to ask questions and listen to the answers provided by the people who are willing to give them, such as myself.

I don’t mind answering question after question when I have spare time (which I don’t anymore, so I cut back). Some of the questions are nearly identical such as “Has anybody used ?” or “Can somebody help me?” or “This is broken.” This is why I made the bot for the channel so that the people helping out do not have to repeat themselves. The bot provides many things, such as the commands !used, !ask and !elaborate for the responses to the respective questions above. I think it’s a great advantage having something like that in the channel and I can see that other people do too.

Sometimes though, we have to answer the questions ourselves. The channel bot does not have the knowledge we do, and is really only helpful for answering general questions or linking to helpful things like the guides. When we answer these questions, we (read: most of us) put our heart and soul into helping you become a better person. We give free advice to those who ask for it.

Many of these people are thankful, grateful, appreciative. I want to see these people become contributing members to the Rails community, so I help them. This is how I got started, and how I need them to get started too. In helping these people, perhaps I learn something new, or perhaps I don’t. It’s those little things you pick up along the way by helping out others which I think makes me a great programmer. The feeling you get when somebody says “Thanks” when you help them is awesome. If I didn’t need to eat, sleep or drink, I could probably live off this alone.

Then you get the people who question your advice. Who state, adamantly, that your advice is wrong. Very, very, very rarely this is the case. It’s usually that they’ve come in with their own set opinion and that anybody else who says anything different is completely wrong. I do not understand these people. They come in asking what appears to be a legitimate question, but instead will argue with you for hours as to why their point is better, regardless of your experiences and issues with their point.

Listen to us. We’ve been there before. We know what’s best (99.999% of the time). If you think that you’re right, stop and think for a moment. What if the other person is right? Try to see it from their point of view. Imagine what it would be like to argue their point. Don’t come back with things like “NO THAT SUCKS”. Clearly elaborate on why it sucks in clear and concise points. Text is not limited and your time is not as precious as you think. The more valid points you have for your argument, the better it will be. Arguing with the longtimers in the channel is not the way to win friends and influence people. Admit you’re wrong if you are, and you’ll be a better person for it.

Stop assuming that your answer is the be-all-and-end-all of the topic. Why waste our time asking a question if you’re already set in your ways? Just go and implement it and then come to us later when it breaks for you and we will help you fix it for free. If 5 other people in the channel are opposing your idea and suggesting what they claim is a better solution, then they’re probably right. We only have your best interests in mind.

Please, listen to us. We want you to help you, help us, help you.

Classes are cached in the test environment

Thursday, May 6th, 2010

I mentioned yesterday that I was saving juicy topics for the book I’m writing, but this is just one that’s too good to miss from posting here too. Consider it (and the posts before it) a sample. The book is in a very similar vein.

Today we were working on our application at work which we refer to as three-point-oh. In three-point-oh, there were some features that were broken unrelated to the work we were currently doing on the donations branch which we had just merged into master. It was one of those issues where you could run the features that were breaking by themselves and they’d work just fine.

You know the type.

In our system we have an ActivityObserver which creates an Activity record every time someone performs any kind of CRUD action upon any observed class in our system. The catch is that User.current_user must be set for an activity record to be created, otherwise there’s no record of CRUD.

One of the observed classes was Contact. One of our features runs the db:seed task for its own setup (the very first line of the Background) and in this we set up a Contact record for the scenarios. Of course by it being the first line, we’re not going to have a currently logged in user, and therefore an Activity record is not going to be created.

But what happens if we run another scenario where we log in? Well, then User.current_user will be set to that user whom we log in with. Then, of course, Cucumber will perform its dutiful task once the scenario has finished running and clear the database, thereby eradicating all records, including the one that User.current_user is set to . What Cucumber does (and should) not do is destroy objects. When we ran the features in a group, if any of those features were logging in they would be setting User.current_user, then of course that related record would be being wiped when the scenario completed.

Then came the seeding feature. This is the feature that runs the db:seed task for itself and because User.current_user was set in a prior ran feature, it was creating Activity records for users that no longer exist. When the app then went to display these activities on the homepage, it would attempt access the avatar method on a user that no longer existed, thus giving us an undefined method avatar for nil:NilClass.

This was because between requests in test mode, classes are not reloaded. Therefore, User.current_user would not be unset. To unset it, we specify this in a file located at features/support/start.rb:

Before do
  User.current_user = nil
end

We could probably also use foreign key constraints to ensure that when we create an activity record that the user record we’re creating it for exists, but that’s information probably best kept for the book or another blog post.

Rails 3 Book: Week 3

Wednesday, May 5th, 2010

Well, not really Week 3, but it’s the start of the third week since I announced it, so it’s the “official” 3rd week. I recorded another video last night. Much shorter than the last one (6’15) and it should give you a good insight into what I’m doing this week.

Rails 3 Book: The Movie

Friday, April 30th, 2010

So I posted earlier that I’m writing a book on Rails 3 and I asked for suggestions. Thank you greatly to those who sent them in. Now I’m looking to put the final touches on the book and because I was slightly inebriated when I got home I decided to record something in Photo Booth rather than writing it down.

So here it is. If you’ve ever wanted to stare lovingly into my eyes and hear my soothing voice, here’s your chance.

Hopefully with your feedback by the end of next week I should have a good enough table of contents to start writing this epic.

Thanks for being with me so far!