westonganger / protected_attributes_continued

The community continued version of protected_attributes for Rails 5+
MIT License
45 stars 33 forks source link

Possible fix for new records in Rails 6 #18

Closed jonknapp closed 4 years ago

jonknapp commented 4 years ago

Related to https://github.com/westonganger/protected_attributes_continued/issues/15, I was having issues with any new records that were supposed to be created issuing UPDATE sql calls instead of INSERT. They would come back thinking they were persisted, but they didn't have an id attribute because of the invalid sql call made.

I looked through forks of this project and found one with a one line commit that fixed the immediate issue I was having, though I'll be testing this out more as I prep a Rails 6 release for a legacy project.

The code was originally found at https://github.com/zarmin/protected_attributes_continued/commit/532b731b6306abca2c23d86cb674b15dbc30ab50

westonganger commented 4 years ago

Thanks @jonknapp looks good. Please follow up with your results after further testing

jonknapp commented 4 years ago

Will do. I wouldn't merge anything yet, but wanted to raise the visibility of the fix in case it helps others. My project's test suite is green but that doesn't mean much since there isn't that much coverage.

jonknapp commented 4 years ago

FWIW I have seen no other issues from the testing of a Rails 6.0.3.3 server so far.

westonganger commented 4 years ago

Thanks for the update. Merged. Thanks for your contribution!

lukebooth commented 3 years ago

I can't stress enough how important this update is/was. I was on version 1.5.0 when trying to upgrade to Rails 6. I spent a day and a half trying to figure out why, when running migrations, the ran migrations wouldn't save the version to schema_migrations table. Even when debugging checking that the new ActiveRecord::SchemaMigration entry persisted? => true 😅 😅 😅

I wish this could be floated up to Google search results for better recognition for other developers who might have the same issue.