Include methods from model?
jemminger opened this issue · comments
Jeff Emminger commented
Is it possible to include methods as well as columns/associations?
For example with as_json
, you can include methods from the model: my_object.as_json(methods: [:this_method, :that_method])
and get back
{
id: 1,
name: "Foo",
this_method: "some value",
that_method: "another value",
...
}
Jeff Emminger commented
Ah, thinking about it more I guess it's not possible, since you're retrieving straight from PG which would have no knowledge of the model's methods.
Jack Christensen commented
Correct. There's no way to do that without some serious hackery.