mwpastore on namespace-dsl
wip (compare)
mwpastore on master
Update Sinatra dependencies (compare)
mwpastore on v1.3.0
mwpastore on master
Bump to 1.3.0 (compare)
mwpastore on master
Deprecate `sinja {}' in favor o… Make sure Rubygems is up-to-dat… Dynamic before_<action> arity and 5 more (compare)
email
serialize_models()
is the right answer, but I'm struggling to see how to pass it the options I want (namely how to exclude a field)
fields
JSON API query parameter (http://jsonapi.org/format/#fetching-sparse-fieldsets)
index(roles: %i[user trusted]) do
Models::User.all
end
index(roles: %i[user trusted]) do
serialize_models Models::User.all, fields: { users: indexable_fields }
end
@body=["{\"data\":[],\"jsonapi\":{\"version\":\"1.0\"},\"included\":[]}"]
serialize_models
directly in the index
sinja route helper
def before_index
params[:fields] = {
users: if params[:fields] && params[:fields].key?(:users)
params[:fields].select { |k, _| indexable_fields.include?(k) }
else
indexable_fields
end
}
end
serialize_models
is called behind the scenes), along with a hash of options to pass to jsonapi-serializers. and you can't use return
, you have to use next
. so you wantedindex(roles: %i[user trusted]) do
next Models::User.all, fields: { users: indexable_fields }
end
before_index
(and before_show
, etc.) to set defaults for query parameters like include, fields, sort, filter, page, etc.