My use case is that I'm using Grape API with Sequel. I have it set to 
automatically convert returned values to json for me, so the 
to_json(:include) doesn't work for me unless I were to either disable the 
automatic json conversion for that route (not sure if possible), or call 
to_json and then parse the json back to a hash, which is really no better 
than just mapping the relation myself.

Not sure how many people have similar circumstances though, you're right.

On Thursday, April 30, 2015 at 4:51:33 PM UTC-7, Jeremy Evans wrote:
>
> On Thursday, April 30, 2015 at 4:09:53 PM UTC-7, Jon Mattingly wrote:
>>
>> Is there a method similar to calling object.to_json(:include => 
>> :relation) when you're calling object.to_hash?
>>
>> Right now the best I've been able to come up with is mapping the object's 
>> relation to the hash myself.
>>
>
> Not currently. Model#to_hash has always just been an alias for values.  I 
> don't want to modify the Model#to_hash API, but I suppose I could consider 
> adding a method.  I'm not sure it would be used enough to be in the core, 
> it probably belongs in a plugin if it is added.
>
> Thanks,
> Jeremy
>

-- 
You received this message because you are subscribed to the Google Groups 
"sequel-talk" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To post to this group, send email to [email protected].
Visit this group at http://groups.google.com/group/sequel-talk.
For more options, visit https://groups.google.com/d/optout.

Reply via email to