-
Notifications
You must be signed in to change notification settings - Fork 633
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
When used with ActiveRecord, AASM does not check that fields are in the backing db #152
Comments
@alto I can try to do this. What branch should I use? |
@alto I was looking for some issue to contribute, if you want, I will try to send you a pull request. I asked in what branch should I work on it ? |
@fabioperrella Ah, now I understand. There are two main branches currently worked on, master and multiple_state_machines_per_class. I would recommend to branch from master, because the multiple one is changing quite a lot. Thanks for your help. I really appreciate this! |
@michaeldickens I tryed to reproduce your error but I couldn't. I created a class using aasm and didn't migrated the DB (the column aasm does not exist), then when I called the method .aasm_state, it raised the error NoMethodError: undefined method `aasm_state' for #<Account id: nil, name: "aa"> |
When using enum for state column and enum config not set explicitly, if column is not present in database then "NoMethodError: undefined method 'type' for nil:NilClass" was raised for transitions which is hard to debug. Fix aasm#152
@michaeldickens I just released version |
When using enum for state column and enum config not set explicitly, if column is not present in database then "NoMethodError: undefined method 'type' for nil:NilClass" was raised for transitions which is hard to debug. Fix aasm#152
When using enum for state column and enum config not set explicitly, if column is not present in database then "NoMethodError: undefined method 'type' for nil:NilClass" was raised for transitions which is hard to debug. Fix aasm#152
I recently encountered a bug in some code I wrote where I was attempting to access an AASM state from the backing database associated with an ActiveRecord. I hadn't migrated the database, so AASM couldn't find the column in the database. Instead of returning a helpful error, it said,
NoMethodError: undefined method
type' for nil:NilClass. I discovered that this happens in active_record_persistence.rb:131 when
self.class.columns_hash[self.class.aasm_column.to_s].typecalls
typeon a
nil` value. It would be helpful if AASM checked that the field was in the database before trying to operate on it.The text was updated successfully, but these errors were encountered: