palkan/store_attribute

BUG: v1.0.1 non-typed attribute names don't include prefix or suffix

Closed this issue · 2 comments

Tell us about your environment

Ruby Version:
3.0.4

Rails Version:
6.1.5.1

PostgreSQL Version:
12

Store Attribute Version:
1.0.1

What did you do?

We've attempted to use prefixes with non-typed attributes (example below).

class Space::TestObject < ActiveRecord::Base
  store_accessor :notes, :for_manager, prefix: :note
end

What did you expect to happen?

A method for "note_for_manager" to be defined.

What actually happened?

ActiveModel::UnknownAttributeError: unknown attribute 'note_for_manager' for Space::TestObect.

It looks like the prefix (and suffix) values were unintentionally omitted in a recent changeset. https://github.com/palkan/store_attribute/blob/v1.0.1/lib/store_attribute/active_record/store.rb#L63

As a workaround, providing a type to the attribute works as expected.

class Space::TestObject < ApplicationRecord
  store_accessor :notes, for_manager: jsonb, prefix: :note
end

Thanks for the report! Fixed.

Released in 1.0.2