Open
Description
Expected behavior vs actual behavior
I expect conditionals for attribute
and attributes
to behave the same, but they don't. An example:
class UserSerializer < ActiveModel::Serializer
# Just some attributes...
attributes :id
# NOTE: attributes in plural!
attributes :secrets, if: :admin_signed_in?
def admin_signed_in?
# Some authentication logic...
end
end
This gives me TypeError ({:if=>"admin_signed_in?"} is not a symbol nor a string):
If I change this it to attribute
in singular, it works!
attribute :secrets, if: :admin_signed_in?
Environment
ActiveModelSerializers Version (commit ref if not on tag): 0.10.0
Output of ruby -e "puts RUBY_DESCRIPTION"
: ruby 2.2.5p319 (2016-04-26 revision 54774) [x86_64-linux]
OS Type & Version: Ubuntu 16.04
Integrated application and version (e.g., Rails, Grape, etc): Rails 4.2.4