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

Annotate no longer works with Rails 5.2 models #538

Closed
kieraneglin opened this Issue Dec 21, 2017 · 11 comments

Comments

Projects
None yet
10 participants
@kieraneglin

kieraneglin commented Dec 21, 2017

On Rails 5.1, annotate worked as expected. After updating to 5.2, I noticed that annotate was not working as part of my post-update functionality testing.

I have no frozen string literal comments in my models.

Sample output:

Warning: exception can't modify frozen String raised while trying to load model class app/models/user.rb
Unable to annotate app/models/game.rb: can't modify frozen String
Unable to annotate app/models/game.rb: no implicit conversion of nil into Array
Unable to annotate app/models/user.rb: can't modify frozen String
Unable to annotate app/models/user.rb: no implicit conversion of nil into Array
Model files unchanged.

I'm unsure if this affects anything except models, since that's the only functionality I'm using.

Versions
Rails: 5.2.0.beta2
Ruby: 2.4.2
Annotate: 2.7.2

@ctran

This comment has been minimized.

Owner

ctran commented Dec 22, 2017

Have you tried it the dev version of annotate gem (see README for instructions)?

@kieraneglin

This comment has been minimized.

kieraneglin commented Dec 27, 2017

Sorry for the delay! I've been busy with holidays and all.

Updating to the dev version mostly works. However, using ActiveStorage's has_one_attached (see here) trips it up with the following error:

Warning: exception can't modify frozen String raised while trying to load model class app/models/user.rb
Model files unchanged.

It seems to still annotate the model (and all other models work fine), but the error is still raised.

Let me know if you need any more information!

@kuroda

This comment has been minimized.

Contributor

kuroda commented Jan 7, 2018

@ctran I have same problem on Rails 5.2.0.beta2 and the dev version of annotate gem.

Error messages:

Unable to annotate app/models/author.rb: can't modify frozen String
Unable to annotate app/models/author.rb: no implicit conversion of nil into Array

I have three models (Category, Post and Author). The former two models get annotated correctly, but the last one (Author) can not be annotated.

@kuroda

This comment has been minimized.

Contributor

kuroda commented Jan 7, 2018

@ctran I noticed an interesting phenomenon.

Annotation goes well on the tables that have foreign key constraints.

In order to confirm my theory, I added a column with foreign key constraint to the authors table.
Then, the Author model gets annotated correctly.

@fshin1988

This comment has been minimized.

fshin1988 commented Jan 13, 2018

I have same issue with following versions.

ruby 2.5.0
rails 5.2.0.beta2
annotate 2.7.2
@damienlethiec

This comment has been minimized.

damienlethiec commented Feb 8, 2018

Same here, with same versions as @fshin1988 except rails 5.2.0.rc1

@ammit

This comment has been minimized.

ammit commented Feb 18, 2018

@kuroda, same here
Model without index (belongs_to association) on any other column may be causing this issue.

Setting 'show_indexes' => 'false', annotated the model.

@buren

This comment has been minimized.

buren commented Feb 19, 2018

Also on Ruby 2.5, Rails 2.5.0.beta2 and annotate 2.7.2.

Setting 'show_indexes' => 'false', annotated the model.
- #538 (comment)

Can confirm that this works 👍 Thanks [at]ammit

@6temes

This comment has been minimized.

6temes commented Mar 17, 2018

Same thing with 2.5, Rails 2.5.0.rc1 and annotate 2.7.2.

RStankov added a commit to RStankov/ConferenceBox that referenced this issue Mar 17, 2018

Fix annotating models
There is issue with has one attached file. Solution is to don't show indexes.

More info:

ctran/annotate_models#538
@bambery

This comment has been minimized.

bambery commented Apr 15, 2018

Setting "show_indexes" to false allows this gem to work in Rails 5.2.0

@ota42y

This comment has been minimized.

ota42y commented Apr 16, 2018

This problem already solved but haven't released... 😢
#517

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment