Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Ignoring Redis fields that are missing in the model? #234

Open
rgaufman opened this issue May 24, 2018 · 4 comments
Open

Ignoring Redis fields that are missing in the model? #234

rgaufman opened this issue May 24, 2018 · 4 comments

Comments

@rgaufman
Copy link

When I change my model, any fields that are still present in Redis cause a NoMethodError, e.g.

> Device.all.entries[0]
Traceback (most recent call last):
        2: from (irb):5
        1: from (irb):5:in `entries'
NoMethodError (undefined method `created_at=' for #<Device:0x0000000004c48278 @attributes={}, @_memo={}>)

Is there any way to get Ohm to ignore any fields from Redis that are not in the model? - or is there some other recommended strategy to handle this?

@soveran
Copy link
Owner

soveran commented Jun 4, 2018

@rgaufman I will work on this. I did some experiments in the past and it's true that those cases should be handled in a better way.

@carina-akaia
Copy link

irb(main):012:0> Transaction[3].remove NoMethodError: undefined method 'timestamp=' for #<Transaction:0x0000561b588b76e8>
I have the same problem when try to delete object with the attribute, deleted from model before

@pote
Copy link
Contributor

pote commented Jun 17, 2018

Maybe just having more explicit exceptions that suggest the standard solution to the problem would be enough?

@katecanaveral this happens because you'd have to set to nil the attribute in all objects before you remove attribute :timestamp from your code, since the Transaction#timestamp and Transaction#timestamp= methods are defined by Ohm when attribute is present.

If I'm not mistaken, the process would be:

  1. Set all Transaction#timestamp to nil - with a migration-like script or manually.
  2. Remove attribute :timestamp.
  3. Deploy the new code.

@carina-akaia
Copy link

@pote thanks for the solution

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

No branches or pull requests

4 participants