Category Archives: Ruby

Comments and notes about developing using Ruby

Comments in Gemfile

I wish people would take a little time to consider the best way to arrange and comment the gem insertions in Gemfile. I am not a great fan of commenting. I believe you should code so that it is easily … Continue reading

Posted in Ruby | Comments Off on Comments in Gemfile

Initialize: keep it simple

The more objects I build, the more I am realising that I need to keep my initialize methods simple. Not doing so, leads to problems later on. The key is in the name: best practice is to keep the initialize … Continue reading

Posted in Ruby | Comments Off on Initialize: keep it simple

Do not put hyphens in engine names

I’m currently working on my first rails 3.1 engine and have just wasted a day or so because I put a hyphen in the engine name. The reason I did this was to be consistent with some other plug-ins I … Continue reading

Posted in Ruby | Comments Off on Do not put hyphens in engine names

Acts As Soft Delete By Field

I’ve had a bit of spare time recently, so I thought it was about time that I created a public gem. I thought about my code and decided that my soft delete system would be a good place to start. … Continue reading

Posted in Ruby | Comments Off on Acts As Soft Delete By Field

Model inhertiance

I’m working on an application with some CMS features. One requirement is that new content is moderated before being published. To enable this, some users are allocated as moderators. To achieve this I have a moderator status column which can … Continue reading

Posted in Ruby | Comments Off on Model inhertiance

mongrel_service on Windows 7 64bit

My current applications run on Linux in production, but I still develop on Windows PCs. My main works PC runs Windows 7 Pro 64bit. This isn’t too much of a problem. Just a couple of things don’t work (like wicked_pdf), … Continue reading

Posted in Ruby | Comments Off on mongrel_service on Windows 7 64bit

Time format

I found an interesting article by Todd Sayre on time formats in Rails. It is only short, but interesting. Based on that I created config/initializers/time_formats.rb in my latest app: # Used to create time and datetime formatting short cuts. Search … Continue reading

Posted in Ruby | Comments Off on Time format

Logging activity within a Rails application

I wanted to add a tool to log users’ activity in my current application. I wanted something simple, and decided that the solution was to combine two techniques: One: making session data available at the model and observer level. An … Continue reading

Posted in Ruby | Comments Off on Logging activity within a Rails application

attachment_fu – working with database file storage

Once I had attachment_fu working with files stored within the Rails application file system, I hit a problem as I wanted to be able to share files across three applications. The problem being that if the file was uploaded in … Continue reading

Posted in Ruby | Comments Off on attachment_fu – working with database file storage

Unit testing attachment_fu

I’m working on a portion of my latest application that will need a facility to upload files. As these files are not images, I decided to use the plug-in attachment_fu. The thing that has caused me the most head scratching … Continue reading

Posted in Ruby | Comments Off on Unit testing attachment_fu