On Sunday, July 12, 2015 at 6:26:41 AM UTC-7, Wesley Key wrote:
>
> When using the JsonSerializer plugin in junction with Sequel.as(), you
> receive a undefined method error for *column_alias*.
>
> An example
>
> Country.select(:id, Sequel.as(:country_name,
> :name)).where(Sequel.ilike(:country_name, "b%")).all.to_json
>
> NoMethodError: undefined method `name' for #<Country @values={:id=>17,
> :name=>"Bahamas"}>
>
That's because like most Sequel code, it calls methods to get the values.
In this case, method name does not exist, so you get the NoMethodError.
For what you are doing, it looks like you are only aliasing to get JSON to
use a key of name instead of country name. You don't appear to be using
any of the featrues of json_serializer, so the easiest way to get what you
want working is to use naked.all instead of all. That way you end up
calling Hash#to_json intead of Sequel::Model#to_json, and things should
just work.
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.