-
Notifications
You must be signed in to change notification settings - Fork 1.2k
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
Adds support for horizontally sharded database projects #1079
Merged
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
can you rebase this PR ? |
@seuros more than happy to. |
f1sherman
added a commit
to f1sherman/acts-as-taggable-on
that referenced
this pull request
Aug 29, 2022
Rails [Zeitwerk](https://github.com/fxn/zeitwerk) autoloader is a lot more strict about when constants are loaded than the old autoloader. I noticed that in mbleigh#1079 `base_class` is being set to the actual class in an initializer, which results in an `unintialized constant` error when the autoloader is set to Zeitwerk. This fixes the setting to work in Zeitwerk by allowing it to be set to a `String` which gets constantized later, after initializers have run. I also fixed the initializer example to call the `setup` method, which I believe is the recommended way to do that.
seuros
pushed a commit
that referenced
this pull request
Jan 18, 2023
Rails [Zeitwerk](https://github.com/fxn/zeitwerk) autoloader is a lot more strict about when constants are loaded than the old autoloader. I noticed that in #1079 `base_class` is being set to the actual class in an initializer, which results in an `unintialized constant` error when the autoloader is set to Zeitwerk. This fixes the setting to work in Zeitwerk by allowing it to be set to a `String` which gets constantized later, after initializers have run. I also fixed the initializer example to call the `setup` method, which I believe is the recommended way to do that.
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
In our project we're using a horizontally sharded database in Rails 6.1. As part of that we have to define what shards our different models can connect to through ApplicationRecord. As the gem is currently, the taggings and tags tables we use from the gem would not have access to the right connection information since they inherited from ActiveRecord::Base. It seemed like this might help more than just my project.
This PR makes the class
ActsAsTaggableOn::Tags
andActsAsTaggableOn::Tagging
inherit from a configurablebase_class
variable on ActsAsTaggableOn. A rake taskacts_as_taggable_on:sharded_db:install_initializer
is provided that will add an example initializer to a project.The class passed to
base_class
is checked to be a Class object, otherwise an error is raised.Tests verify that
ActsAsTaggableOn::Tags
andActsAsTaggableOn::Tagging
inherit from ActiveRecord::Base by default or the passed class if present.