Skip to content

Setting attributes through their string name doesn't mark the record as dirty #32

Closed

Description

@pilaf
class MyLayout < FmRest::Spyke::Base
end

m = MyLayout.new("Random Attribute" => "value")

m.changed? # false

This prevents the record from being saved properly as fmrest depends on dirty attributes for persistence.

This needs either a code fix or a warning in the README.

Activity

  1. self-assigned this
    on Oct 10, 2019
  2. added
    bug
    on Oct 10, 2019
  3. mameier commented on Aug 5, 2026

    @mameier

    Attributes have to be declared with attributes to be tracked.
    The rails (ruby) name must be a valid method name.
    It's hard to set up a method called Random Attribute=(value) in ruby.
    So IMHO this is not a bug but something to explain in the docs that this example has to be:

    class MyLayout < FmRest::Spyke::Base
      attributes random_attribute: 'Random Attribute'
    end
    
    m = MyLayout.new(random_attribute: "value")
    
    m.changed? # true
  4. pilaf commented on Aug 7, 2026

    @pilaf
    CollaboratorAuthor

    Closed with updated README in #58

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

bug

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions