Poke me on GitHub

[Rails Tip] DataMapper M:M Association Bug and Workaround

It was confirmed that DataMapper is incorrectly setting table names in SQL JOINs.

So for instance, the following code would generate an SQL error:

type.jobs.all(:"country.name".like => "%#{params[:location]}%")

There is a workaround, however the workaround requires manual looping of the dataset thus produces N+1 queries.

type.jobs.all.reject do |job|
  ! job.country.name.downcase.include?(params[:location].downcase)
end

But at least it works. ;)

Back to top



 

Who am I?

My LinkedIn Profile

me

Grew up in Shanghai, China, I quickly became interested in computers and the Internet at the age of 13. I started off by creating simple websites using basic HTML I learnt from reading computer magazines. Later on I worked in online publishing, marketing and web hosting while studying in high school. After being a 'webmaster' for a few years, I began my career in web development and design. I studied for Bachelor of Information Technology and Systems at Monash University in Melbourne, Australia. I now work as a web developer at Envato.

skills

I am primarily a Ruby and PHP developer as well as a front-end/UI developer. In my spare time I also try to do as much creative designs as I could in order to keep my design skills polished. I also focus strongly on user experience and user interface design.

exp

During high school I worked as a part time site editor for a gadget website as well as a freelancing author, I contributed articles for many of the Chinese IT magazines. Soon I became fascinated by the World Wide Web so I started making my own websites and started hacking scripts. I began working as a part time web developer shortly after I graduated from high school. During the four years of study at TAFE and university, I worked as a freelancer and focused mostly on web development and design. I worked full time as a web developer at a Melbourne-based media agency before landing my current job at Envato.

oss

I am an active open source developer who contributes to many of the projects on GitHub.

Here is a list of my open source projects.

I have also made contribution to these open source projects.

hi!

Please feel free to shoot me an email if you would like to get in touch. I am also happy to provide estimates and consultancy to any web based projects. You may write to me in English or in Chinese. :)