Sep 11, 2014
ActiveModel::Serializers gives you a lot of flexibility and modularity when it come to generating JSON for your Rails api. Serializer just work when the serializer is named after the model it references (
MyModelNameSerializer). You also knew you could easily extend a base ActiveModelSerializer using class inheritance MyExtendedSerializer < MyModelSerializer. Recently, however, I found myself building a serializer that couldn't be named by ActiveModel::Serializer convention and couldn't inherit from the base serializer for that class.
So where does this gem find it's dependent class?
It turns out that the method
Serializer#model_class, defined on Serializer defines this behavior. It was relatively simple to override this behavior: Just override this method in your serializer so that the class method model_class refers to the parent class.
Jun 10, 2013
Today, I happened upon a situation where I needed to pass an argument into my rake task. In the past I've passed an argument using an array-like syntax like like
this post describes. While this works, I didn't really like the syntax and it didn't seem...
Mar 16, 2013
In the past year, I've quit my comfortable job, started my own consulting business, moved to another country (한국!), learned ruby on rails and started working on product at a
startup. It's been a whirlwind of a year and I've learned a ton about taking...
Feb 21, 2013
I had a particularly stark reminder today of why it is still important to do cross-browser testing. While IE8 has now
fallen below 25% market share, it still makes up a significant chunk of the traffic that hits our app each day. One simple bug in...
Nov 13, 2012
I'm using the convenient
Kaminari pagination gem for search results on a current project. The project is primarily focused on function over form and I'm using the
Bootstrap defaults for most of the design. Bootstrap usually works really well with Rails...