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

Add Rails 6.0 compatibility #4789

Merged
merged 5 commits into from
Mar 23, 2022
Merged

Add Rails 6.0 compatibility #4789

merged 5 commits into from
Mar 23, 2022

Conversation

javierm
Copy link
Member

@javierm javierm commented Mar 21, 2022

Objectives

  • Make code compatible with both Rails 5.2 and Rails 6.0, so upgrading will be easier
  • Correctly render custom "proposals/show" views from the proposals#created action
  • Fix taggings returned by the public API

The `only:` key does not apply to model callbacks. It was added in commit 1077e25, probably by accident.

Using this key raises an error in Rails 6.0.
We did a similar change in commit 47925fb, and we were getting a
warning in Rails 6.0:

DEPRECATION WARNING: render file: should be given the absolute path to a
file

Since using `render file:` would ignore views in custom folders, we're
using `render template:` instead.
We were getting a warning in Rails 6:

DEPRECATION WARNING: ActionView::Base instances should be constructed
with a lookup context, assignments, and a controller.
In SQL, conditions like:

```
tag_id IN (x) AND taggable_type='Debate' OR taggable_type='Proposal'
```

Don't work as intended; we need to write:

```
tag_id IN (x) AND (taggable_type='Debate' OR taggable_type='Proposal')
```

Due to this bug, we were returning taggings for proposals without
intending to do so.

Since the code was very hard to read, we're also simplifying it.
We were getting a warning in Rails 6.0:

DEPRECATION WARNING: Class level methods will no longer inherit scoping
from `public_for_api` in Rails 6.1. To continue using the scoped
relation, pass it into the block directly. To instead access the full
set of models, as Rails 6.1 will, use
`ActsAsTaggableOn::Tag.default_scoped`.
@javierm javierm self-assigned this Mar 21, 2022
@javierm javierm added this to Reviewing in Consul Democracy via automation Mar 21, 2022
Consul Democracy automation moved this from Reviewing to Testing Mar 23, 2022
@javierm javierm merged commit 12460c2 into master Mar 23, 2022
@javierm javierm deleted the rails_6.0_compatibility branch March 23, 2022 13:14
Consul Democracy automation moved this from Testing to Release 1.5.0 Mar 23, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants