Skip to content

blank? returns false for a nested resource that is null #187

@dim882

Description

@dim882

I'm just getting started with her, so let me know if I'm simply doing it wrong.
When a nested resource is null, I'd expect blank? to return true but it returns false.

Here's a stripped down version of my code and the resource:

class Thing
  include Her::Model

  has_one :photo
end

class Photo
  include Her::Model
end

...

[
    
{
        id: 1,
        name: "Something",
        photo: null
    },
    {
        id: 2,
        name: "Something else",
        photo: {
            id: 101,
            url: "http://example.com/image.png"
        }
    }
]

...

things = Thing.all()
things[1].photo.url # =>  "http://example.com/image.png"
things[0].photo.blank? # => false
things[0].photo.url # => NoMethodError: undefined method `empty?' for nil:NilClass

Is this a bug or do I have my models set up incorrectly? Thanks.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions