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
Upgrade Rails to 5.2.3 #1408
Upgrade Rails to 5.2.3 #1408
Conversation
|
This is awesome @rhymes ! Can I see what error you are experiencing with Algolia? |
|
@maestromac I ran The short error is 1) ChatChannelMemberships POST /chat_channel_memberships creates chat channel invitation
Failure/Error: cache_name = "user-#{id}-#{updated_at}/followed_tag_names"
ActiveModel::MissingAttributeError:
missing attribute: updated_at
# ./app/models/user.rb:264:in `cached_followed_tag_names'
# ./app/models/user.rb:486:in `tag_list'
# ./app/controllers/chat_channel_memberships_controller.rb:12:in `create'
# ./spec/requests/chat_channel_memberships_spec.rb:18:in `block (3 levels) in <top (required)>'
# ./spec/rails_helper.rb:57:in `block (3 levels) in <top (required)>'
# ./spec/rails_helper.rb:57:in `block (2 levels) in <top (required)>'The long error is here: ccm.txt It's triggered by this line: https://github.com/rhymes/dev.to/blob/rhymes/rails-522/app/controllers/chat_channel_memberships_controller.rb#L12 |
|
Apparently they fixed the bug I submitted - rails/rails#34780 - with this PR - rails/rails#34885 🎉 |
|
As per @rhymes , we'll wait for the next minor release of Rails 5.2 |
|
@maestromac I'm giving you an update:
If you have any ideas let me know. A side note: the update changed |
|
I re-ran I wonder if this closed algoliasearch-rails issue has something to do with what is happening, it's a russian doll of callbacks and monkey patching, one of those few things I dislike about Rails gems :D I'll keep hunting for the bug. I reckon I should try to trigger it in development mode and not just during the test to see if it fails there as well |
|
Ok I've narrowed it down to these lines that I executed in the Rails console: cc = ChatChannel.last
cc.index! # this works
ccm = ChatChannelMembership.create(user_id: User.first.id, chat_channel_id: cc.id, status: "pending")
cc.index! # this breaks
ccm.destroy!
cc.index! # this worksBasically, indexing the 🤷♂️ |
|
I think I'm close to the solution and I think an exception is masked by another one: on master the serialization of the dynamic field I've narrowed it down more to https://github.com/algolia/algoliasearch-rails/blob/d389875f5c07b7e405eb0786d10f6738bff1c2f1/lib/algoliasearch-rails.rb#L173 that calls: Hash[attributes.map { |name, value| [name.to_s, value.call(object) ] }]
def pending_users_select_fields
pending_users.select(:id, :username, :name)
endinside On master that select produces:
ends up in the hash to be serialized and goes on with its business. On Rails 5.2.3 the same select returns a different type of object:
which seems to break the association. As a confirmation, if I remove I'm definitely close to the solution :D UPDATE: this made it work for me locally - 52a5834 - apparently the indexed relationship needs to know about |
|
@rhymes 👏 how did you figure out that it needs |
|
@maestromac just a hunch - I was lost in the rabbit hole of serialization/deserialization, then I went to eat something and I got the idea :D On a related note: I think they recently changed how relationships in Algolia are supposed to work https://www.algolia.com/doc/framework-integration/rails/indexing/working-with-relationship/ |
|
@maestromac Rais 5.2.3 is officially out :-) https://weblog.rubyonrails.org/2019/3/28/Rails-5-2-3-has-been-released/ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Got local development up and running. Thanks @rhymes !!
|
Woot, woot! Thanks @maestromac - we've worked on this branch for three months :D |
|
and thank you @rhymes for pushing to the finish line! |
What type of PR is this? (check all applicable)
Description
Inspired by #477 I've tried to bump Rails to the latest version, 5.2.2.
In addition to bumping Rails and its dependencies I've upgraded
act-as-taggable-onto 6.0 as @greysteil did earlier, because it's the first version in the changelog to support Rails 5.2: https://github.com/mbleigh/acts-as-taggable-on/blob/master/CHANGELOG.mdLastly, I ran
rails app:updateto upgrade all config files (adding also bootsnap). The update process added code for active storage, a new disabled initializer for content security policy and the framework defaults that in the future can be switched on to mimick Rails 5.2 defaults.I'm currently, locally, fighting an error with Algolia's indexing in the tests with Rails 5.2. Upgrading Algolia's gems to the latest versions does not fix the issue.
If you have suggestions, I'm all hears.
I've also encountered a possible bug (yet to be determined) in Rails 5.2.2 and the handling of the
Cache-Controlheader disallowingpublic, no-cacheas a value. See rails/rails#34780.There's work to do to bring dev.to's source to 5.2 but I think it can be done :)
Related Tickets & Documents
Added to documentation?