Incompatible with gems that call `attribute` in Rails models
Maintainers usually reply within 3 days
@KaanOzkan is already working on this.
Since Dec 6, 2024.
Assessment
This issue has not been assessed yet.
Description
I'm not sure if this is an issue with tapioca or with the downstream gem, but figured I'd report here and you can tell me to go away if necessary :)
To replicate:
rails new tapioca-bug- Add
gem "noticed", "2.4.1"to Gemfile - Add
gem 'tapioca', require: falseto Gemfile bundle exec tapioca init
It will raise like this:
/.rvm/gems/ruby-3.2.2/gems/activerecord-7.2.1/lib/active_record/connection_adapters/abstract/connection_handler.rb:224:in `retrieve_connection_pool': No connection pool for 'ActiveRecord::Base' found. (ActiveRecord::ConnectionNotEstablished)
from /.rvm/gems/ruby-3.2.2/gems/activerecord-7.2.1/lib/active_record/connection_handling.rb:329:in `connection_pool'
from /.rvm/gems/ruby-3.2.2/gems/activerecord-7.2.1/lib/active_record/connection_handling.rb:321:in `connection_db_config'
from /.rvm/gems/ruby-3.2.2/gems/activerecord-7.2.1/lib/active_record/type.rb:50:in `adapter_name_from'
from /.rvm/gems/ruby-3.2.2/gems/activerecord-7.2.1/lib/active_record/attributes.rb:299:in `resolve_type_name'
from /.rvm/gems/ruby-3.2.2/gems/activemodel-7.2.1/lib/active_model/attribute_registration.rb:14:in `attribute'
from /.rvm/gems/ruby-3.2.2/gems/noticed-2.4.1/app/models/noticed/event.rb:15:in `<class:Event>'
from /.rvm/gems/ruby-3.2.2/gems/noticed-2.4.1/app/models/noticed/event.rb:2:in `<module:Noticed>'
from /.rvm/gems/ruby-3.2.2/gems/noticed-2.4.1/app/models/noticed/event.rb:1:in `<main>'
The issue is the , :json here. If you remove that, it works fine, since it doesn't need to do the type lookup anymore.
As far as I'm aware, that approach of putting models in app/models for a gem is valid, but maybe there's a more correct way to structure the gem. In any case, it works fine everywhere apart from this specific case.
The underlying issue, I think, is that Rails thinks there's no connection pool set up. This is not an issue when you boot a Rails app, it's only an issue when tapioca is eager loading.
cc @excid3
- Dominant language
- Ruby
- Stars
- 873
- Forks
- 164
- Avg merge
- 4d 22h
- Merged PRs (30d)
- 9
Getting set up
We have not checked this project's setup files yet. Start from its README, and see our first-contribution guide for the general steps.
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
More from Shopify/tapioca
-
Difficulty 2/5 1-3 hours Newbie friendliness 72/100
Shopify/tapioca#2662 · 1 comment ·
Maintainers usually reply within 3 days
-
Difficulty 5/5 Over a week Newbie friendliness 30/100
Maintainers usually reply within 3 days
-
Prepending a module can cause `tapioca dsl` to produce an untyped signatureMay be free again @KaanOzkan claimed this 32 days ago, and no pull request is open. Openbug
Shopify/tapioca#2705 · 1 assignee ·
Maintainers usually reply within 3 days
-
Difficulty 3/5 1-2 days Newbie friendliness 68/100
Shopify/tapioca#2663 · 2 comments ·
Maintainers usually reply within 3 days
-
Difficulty 3/5 1-2 days Newbie friendliness 55/100
Shopify/tapioca#2631 · 1 comment · 1 reaction ·
Maintainers usually reply within 3 days
Similar issues
-
security
Difficulty 2/5 1-3 hours Newbie friendliness 68/100
Maintainers usually reply within 1 day
-
Mend: dependency security vulnerability
Difficulty 2/5 1-3 hours Newbie friendliness 68/100
Maintainers usually reply within 1 day
-
Mend: dependency security vulnerability
Difficulty 2/5 1-3 hours Newbie friendliness 62/100
-
Difficulty 2/5 1-3 hours Newbie friendliness 75/100
Maintainers usually reply within 1 day
-
homebrew warningsOpen
Difficulty 1/5 Under an hour Newbie friendliness 88/100
bradygaster/squad#2082 ·
Maintainers usually reply within 1 day