Comments (15)
Nice! I was just working on this now. I was working on adding an active_record_adapters
module and was planning on having an adapter for active record 4 and active record 5. I'll leave my thoughts on one vs the other in that PR though!
from sorbet-rails.
Sure -- happy to submit a PR. About to head out for the day, but I'll see if I can send something over later tonight.
from sorbet-rails.
Check out slide 22 of this "RubyKaigi2019 Ruby 3 Progress Report" slide deck regard merged bundler into rubygems:
https://docs.google.com/presentation/d/1z_5JT0-MJySGn6UGrtdafK1oj9kGSO5sGlTtEQJz0JU/edit#slide=id.g55232ea080_0_59
from sorbet-rails.
Oh. It's a version thingy. We've supported 5.1.7 and 5.2.3 currently.
It looks like an easy fix in model_rbi_formatter
-- 4.2.10 probably don't support through_reflection?
.
Please feel free to add support for 4.2.10 following the same pattern it's added for 5.1.7.
We're drafting a Contribution guide but feel free to message me if you run into any issue testing.
from sorbet-rails.
I just checked. Rails 4.2 doesn't have through_reflection?
but it does have a through_reflection
object. The fix might be as simple as falling back to through_reflection.present?
if through_reflection?
doesn't exist
See
https://www.rubydoc.info/gems/activerecord/4.2.4/ActiveRecord/Reflection/HasManyReflection
from sorbet-rails.
I've patched model_rbi_formatter.rb
locally in the following way to get this working. Here is an rbi formatter diff that appears to be working for activerecord 4.2.
< reflection.through_reflection? ?
---
> reflection.through_reflection ?
278c278
< cast_type = ActiveRecord::Base.connection.lookup_cast_type_from_column(column_def)
---
> cast_type = column_def.cast_type
303c303
< when ActiveRecord::Enum::EnumType, ActiveRecord::Type::Binary, ActiveRecord::Type::String, ActiveRecord::Type::Text
---
> when ActiveRecord::Type::Binary, ActiveRecord::Type::String, ActiveRecord::Type::Text
The changes are:
through_reflection
instead ofthrough_reflection?
.- Getting the cast_type is just
column_def
.cast_type - There is no
EnumType
in 4.2
from sorbet-rails.
Thanks @alexevanczuk. Awesome job! Would you like to submit a PR? We're working on adding spec for 4.2 soon!
from sorbet-rails.
@manhhung741
I've begun looking into this, and I've found the following things:
- I'm having difficulties pushing a branch. is there something that needs to be set up on your side or do you know if this is on my side?
~/workspace/sorbet-rails - (ae-support-rails-4.2 !) $ git push
remote: Permission to chanzuckerberg/sorbet-rails.git denied to AlexEvanczuk.
fatal: unable to access 'https://github.com/chanzuckerberg/sorbet-rails.git/': The requested URL returned error: 403
- I'm starting this by working on getting tests supported with Rails 4.2. However, Rails 4.2 requires bundler < 2, and the current lockfile is generated using Bundler 2. I think maybe this library could switch to using https://github.com/thoughtbot/appraisal, which was specifically made for this purpose. It allows for testing against multiple Gemfiles and has support for Travis.
I think getting the Rails 4.2 tests setup would be a nice thing to have prior to doing this. I'd sequence it as follows:
- Transfer existing tests and test set up to use Appraisal
- Add 4.2 tests, skipping tests that fail
- Fix the failing tests using a cleaner version of the diff above, possibly through the use of adapters, or maybe just starting simpler/more explicit by pulling the different parts into a method that is conditional on Rails version.
I'd be happy to help with this, but it will take longer than tonight for me to do this, and I'm heading on vacation for 10 days starting tomorrow night. That being said, still happy to help look into this when I'm back from vacation!
from sorbet-rails.
Ah, you'd have to
- Fork the repo
- Make a commit
- Push to your repo
- Make a pull request
I think getting the Rails 4.2 tests setup would be a nice thing to have prior to doing this
I'm trying to set up tests for Rails 4.2 but it's not trivial. I should have it working soon -- or tomorrow. If you can get sorbet-rails
work with your 4.2 rails app following the CONTRIBUTE guide, it'd be enough to send out a PR. Once the test suite for 4.2 is set up, we can test & merge the PR.
from sorbet-rails.
Appraisal looks promising. I'll look into it too.
from sorbet-rails.
Also, enjoy your vacation @alexevanczuk
@aethos does @alexevanczuk patch work for you?
from sorbet-rails.
Checkout #48 I actually did it. It was crazy to set up spec for 4.2. Thanks to Alex's patch, I didn't have to look too hard into fixing the bugs with 4.2
from sorbet-rails.
Cool. Thank you :-) Please do send it our way. Your adapter maybe useful for handling multiple versions of ActiveRecords in the future.
The issue with setting up 4.2 is mainly in the fact that it needs bundler 1.x whereas some other version only want 2.0. And Travis doesn't like that either.
from sorbet-rails.
I've merged #48. This issue should be fixed and the gem now support Rails 4.2!
from sorbet-rails.
Check out slide 22 of this "RubyKaigi2019 Ruby 3 Progress Report" slide deck regard merged bundler into rubygems:
https://docs.google.com/presentation/d/1z_5JT0-MJySGn6UGrtdafK1oj9kGSO5sGlTtEQJz0JU/edit#slide=id.g55232ea080_0_59
Thanks @jasnow! That's super exciting!
from sorbet-rails.
Related Issues (20)
- Feature: Re-generate model RBIs on db:migrate HOT 2
- Feature: custom methods on associations.
- Signatures not generated for models using new ActiveRecord::DelegatedType
- Has_many with scope on association HOT 2
- Decide whether to drop Ruby 2.4 and Ruby 2.5 HOT 2
- Feature Request: --verify option for CI HOT 1
- FR: helper_generator_class
- Method object does not exist on ActionView::Helpers::FormBuilder HOT 1
- Don't know how to build task 'rails_rbi:routes' HOT 1
- Unable to resolve constant BatchEnumerator HOT 1
- Enum override in ActiveRecordOverrides breaks with Rails 7 HOT 5
- Lots of T.nilable(T.untyped) errors after sorbet 0.5.9556
- Classic Loader issues with srb init HOT 1
- warning: already initialized constant RAILS_RBI_RAKE_DIR
- regression on update to sorbet 0.5.9892+ HOT 1
- `rails_rbi:jobs` raise unknown prefix error HOT 2
- Model with `enum` raises `ArgumentError: wrong number of arguments (given 3, expected 1)`
- Type check errors in generated RBI files HOT 2
- Readme typo custom -> controllers ?
- `pluck_to_tstruct` assigns plucked values to the wrong tstruct keys depending on the order in which the tstruct props for associations are listed
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from sorbet-rails.