Skip to content

Attribute names can't be declared as string #324

@svoboda-jan

Description

@svoboda-jan

Hi,

after upgrading from 0.7.0, I noticed, that when declaring attribute names as strings:

class MySerializer < ActiveModel::Serializer
  attributes "id", "name"
end

An exception TypeError (nil is not a symbol) is raised.

When using symbols everything is ok. Is this expected behaviour ?

I often declare attributes as follows, which results in string attribute names:

class MySerializer < ActiveModel::Serializer
  attributes *%w{ id name }
end

In ruby >= 2.0.0-p0 this can be solved with %i:

class MySerializer < ActiveModel::Serializer
  attributes *%i{ id name }
end

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions