Passing current user id to Rails models

Long time since last post, isn’t it? Well, I’m completely busy with my work in Nettigo, selling Arduinos and other nice gears :) I do not do gigs anymore, so there is a lot less reasons to write about Rails. But I still use this framework, since my backend software is written in Rails, so …

Extracting fixtures

I’m still using fixtures. Shame, I know. Why I do use them instead of Factory Girl or other solution like that? Well, fixtures can be much more closer to real data than mocks from Factory. How come, You ask? Fixtures are imaginary data exactly like mocks from other sources! My answer is: that depends how …

Associations and to_json on collections of objects

ActiveRecord’s Serialization module does provide to_json method. It allows include associations when dumping to JSON, but it works only for single objects. If You want to run it against collection, returned by find :all You will get: >> Model.all.to_json :include =>:association TypeError: wrong argument type Hash (expected Data) from (irb):13:in `to_json’ from (irb):13 If You …

MySQL, collations and Rails – or server, database, connection – that is not all

Last few weeks were somewhat crazy time. But I’m seeing finish line not so far away and I hope to find more time for blogging in upcoming weeks. At least I have few things to share, which could be interesting for other Rails developers. So let’s start with MySQL and it’s collations. I have wrote …