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

Annotate no longer works with Rails 5.2 models #538

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

Annotate no longer works with Rails 5.2 models #538

kieraneglin opened this issue Dec 21, 2017 · 11 comments
Milestone

Comments

@kieraneglin
Copy link

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
Copy link
Owner

ctran commented Dec 22, 2017

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

@kieraneglin
Copy link
Author

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
Copy link
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
Copy link
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
Copy link

I have same issue with following versions.

ruby 2.5.0
rails 5.2.0.beta2
annotate 2.7.2

@damienlethiec
Copy link

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

@ammit
Copy link

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
Copy link

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
Copy link

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
There is issue with has one attached file. Solution is to don't show indexes.

More info:

ctran/annotate_models#538
@bambery
Copy link

bambery commented Apr 15, 2018

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

@ota42y
Copy link

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
Labels
None yet
Projects
None yet
Development

No branches or pull requests

10 participants