Tag: rails
-
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…
-
Test benchmark – useful gem for Rails tests
Doing TDD You need to know which tests are making whole suite slower. If time used by rake test becomes too long, You may be tempted to skip running tests… Waiting for them to complete becomes suddenly burden on Your way to next task. So, when You need to optimize Your test suite, test_benchmark is…
-
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…
-
Reloading Your plugin in development mode
For one of my customers I was developing API, wrapped around some older service. This API was meant to be used by new application developed (using RoR of course) by customer itself. Since I was only wrapping old code I could finish quite soon, before main application was ready. The problem was that API was…
-
Will paginate for rescue
Will paginate is great plugin, used almost by every Rails application I have seen. But I’ve seen this plugin used to generate handful navigation among huge datasets. Well it was written with this in mind, but today I have found another use. How often Your application does need export huge dataset as CSV for example?…