All posts in Rails

I’ve just come across this post on dead simple task scheduling in Rails by the guys at intridea. It looks like a really nifty way to setup scheduled tasks in your Rails app, previously I had my tasks in rake files which I would then hit with cron.

While that is working perfectly adequately for my current setup it does have one downside, when I setup a new server I will have to setup the crontab file too. With this method when I deploy my app my scheduled tasks would get deployed and be running out of the box. Nice.

I've just started using Observers in a Rails application I'm creating and found out that in order to have them picked up by rails you have to manually register the Observers within your environment.rb file, like so:

RUBY:
  1. config.active_record.observers = :my_observer

I like to have as much coverage for any code I write in Rails, such as associations I've created, validation rules etc. I'm not testing the validation itself (Rails' tests have that covered) what I'm testing is that I've actually applied the validation rule.

So I figured that I should do the same for the Observers which should be registered. I couldn't find any references to anyone else doing this so after a little bit of digging I've come up with the following approach for use with RSpec:
Continue reading this entry »

Having spent most of Saturday trying to get files to upload from a Flex application to a Rails backend, fighting against both Flex and Rails all the way, I thought I'd collect together some of the things that have helped me work through this in the hope that others don't have to spend quite as long battling through this. Note however that these are not necessarily best pratices, more a collection of tips that helped me in my situation, there are probably better ways to do some or all of the things that I'll be writing about - and if you know of any improvements/alternatives I'd love to hear about them.
Continue reading this entry »

Sorry for the rather pointless post, I've just finished ensuring our test coverage is up to scratch on our project (as I mentioned in the last post). This means that I can get on with the next stage.

Which also means we're one step closer to releasing it.

Which also means I'm one step closer to being able to tell you all about it, ohhhhh it's so exciting!

Ubuntu Cola, the way to increase RoR productivity on Windows?A couple of weekends ago I was about to begin a large amount of re-factoring of our Ruby on Rails app (more on that to follow) to move it from a functional wireframe of the app to the final polished first version that users can use without cursing us. However I'd knocked together the wireframe version fairly quickly and had not taken time out to put down some decent test coverage, yes I know, and doing the amount of re-factoring I was planning without having any tests to verify that I haven't broken anything isn't a good idea.

So I undertook to get our test coverage up to scratch, I got ZenTest to ensure that the tests get run for every saved modification, which is a great help during development. But this exposed me to something which I had already started to notice but which hadn't become a real issue yet, Ruby on Windows is slower than a 1-legged dog down the dog track. ZenTest was taking 20 seconds or more to even notice a file had changed and then took even longer to begin the test. Combined with Ruby using 100% CPU most of the time this really dented my productivity and I had to do something. Luckily all that spare time I had while I was waiting for the tests to run every time I pressed save meant I could look into resolving the problem.
Continue reading this entry »