Blog (rails)

@fredwu 8 years ago | 11 min read | no comments
About a month ago I was in-between jobs - I had two weeks to rest up, recharge and get ready for my new job. So I thought, I should use those two weeks to learn something new. Years ago I briefly looked into Elixir when it was first released to the wild, at the time I wasn’t interested in picking it up due to its syntax similarity to Ruby, despite their vastly different underlying semantics. I love Ruby, and it’s been my weapon of choice for the past 6-7 years, so when it came time for me to lea...
@fredwu 11 years ago | 11 min read | no comments
This post is about the ruby library we are building - Datamappify, please go check it out. At Locomote we are building a relatively large web application using Rails. Before we began to lay the foundation, we knew very well that if we wanted the project to be maintainable we had to architect the system with extra care and attention. More specifically, we can’t rely on simply using ActiveRecord which combines behaviour and persistence as our domain models. We began our search for something that ...
@fredwu 11 years ago | 2 min read | no comments
Update: You might also want to check out reset_column_information. So a few days ago we started seeing the following errors on our Jenkins builds (swapped with fictional model and attribute names): NoMethodError: undefined method `attack_power=' for #<Ironman:0x00000008525d20> attack_power is a new attribute we recently added to the Ironman ActiveRecord model. I was baffled, as the table column is clearly there but ActiveRecord couldn’t see it. This weird behaviour is confirmed by ...
@fredwu 12 years ago | 1 min read | no comments
Like a lot of places, at Locomote we are building a platform that is API-based. As much as I like having comprehensive test suites, I often feel the need to manually test API endpoints to see exactly what the responses are. Tools such as Postman solves part of the issue: they allow us to quickly test API endpoints without messing with cURL. But as a lazy developer, I want more. ;) I want something that: - automatically generates API endpoints from Rails routes definition - defines input p...
@fredwu 12 years ago | 1 min read | no comments
Ever wondered how you could utilise the render method outside the context of Rails controllers and views? If you wonder why anyone would do that. Well, imagine you are building an awesome form builder, you need to output and/or store rendered partials in the buffer. How do you do that? For example, what if you want to do this in your view? <%=raw Awesome::FormBuilder.new(some_options).html %> You could do something like this: module Awesome class FormBuilder < AbstractController...
@fredwu 14 years ago | 1 min read | no comments
For the past few weeks I have started contributing to a small project - Slim. Slim is a fast, lightweight templating engine for Rails 3. It has been tested on Ruby 1.9.2 and Ruby/REE 1.8.7. Slim is heavily influenced by Haml and Jade. Andrew Stone who is the author of the project has posted a quick update on the latest feature additions to Slim. Please go check it out. The source code of Slim is available on Github.
@fredwu 14 years ago | 1 min read | no comments
Before (Rails 3.0.1pre stable branch + Arel 1.0.1): [] After (Rails 3.1.0 master branch + Arel 2.0.0dev master branch: [] Thanks to the awesome work done by Aaron Patterson (@tenderlove) and others. :-) UPDATE: After Aaron Patteron’s tweet, I ran the tests again on Rails 3.0.1pre stable branch + Arel 2.0.0dev master branch, and the result blew my mind: []
@fredwu 14 years ago | 1 min read | no comments
Don’t you just hate it when you get the following errors during a Capistrano deployment? bundle: command not found Could not find RubyGem bundler (&gt;= 0) (Gem::LoadError) In fact, even if you don’t use bundler, you might still get errors like this: rake: command not found Could not find RubyGem rake (&gt;= 0) (Gem::LoadError) It turns out this has something to do with the $PATH and $GEM_HOME variables. So here’s the quick fix. Log in to your deployment server, as a root us...
@fredwu 14 years ago | 1 min read | no comments
If you haven’t already been using AppConfig in your Rails project, well, you should! Jacques Crocker has recently released his new version of the original AppConfig - RailsConfig. I was invited to join the development of this new tool, so make sure you go check it out. :-)
@fredwu 14 years ago | 1 min read | no comments
I have just pushed a commit that added Rails 2.x compatibility to Inherited Resources Views. Please give it a spin! :-) P.S. I’ve only tested it on Rails 2.3.8.