Open
Description
Expected behavior vs actual behavior
Expected: Only fields passed to only option are returned from as_json
.
Actual: All fields/attributes of the serializer are returned.
Steps to reproduce
- Create an activerecord model called User with attributes: name and status.
- Create a serializer for that model with
attributes :id, :name, :status
- From console execute following steps:
UserSerializer.new(User.new(name: 'foo bar', status: 'active')).as_json(only: [:id, :name]
) - Note that status is also returned.
Environment
ActiveModelSerializers Version (commit ref if not on tag): aa4d89a
Output of ruby -e "puts RUBY_DESCRIPTION"
: ruby 2.3.1p112 (2016-04-26 revision 54768) [x86_64-darwin15]
OS Type & Version: OS X v10.11.5
Integrated application and version (e.g., Rails, Grape, etc): rails 4.2.6
Backtrace
(e.g., provide any applicable backtraces from your application)
Additonal helpful information
(e.g., Gemfile.lock, configurations, PR containing a failing test, git bisect results)