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

rails g merit:install don't generating migrations on Rails6 #351

Closed
rwegrzyniak opened this issue Jul 23, 2020 · 18 comments
Closed

rails g merit:install don't generating migrations on Rails6 #351

rwegrzyniak opened this issue Jul 23, 2020 · 18 comments

Comments

@rwegrzyniak
Copy link

After calling rails g merit:install generator creates initializer and models but don't creating any migrations

@rwegrzyniak
Copy link
Author

To generate migrations I have to run rails g merit:active_record:install

@tute
Copy link
Member

tute commented Jul 23, 2020

Thanks for the report @rwegrzyniak! Is this using latest version, or using master?

@rwegrzyniak
Copy link
Author

I'm using 4.0.0 from rubygems

@rwegrzyniak
Copy link
Author

Also there is a problem with model migration generator even if I call rails g merit:active_record:merit model_name I have error
Could not find "add_merit_fields_to_model.rb" in any of your source paths. Your current source paths are: /usr/local/bundle/gems/merit-4.0.0/lib/merit/generators/active_record/templates
I don't know why it searching for .rb file instead of .erb

@tute
Copy link
Member

tute commented Jul 23, 2020

That last one is fixed in master: 294fd12

@rwegrzyniak
Copy link
Author

I see, but it seems that on rubygems is older version, can I ask you for a small favor and making release or branch? i don't want to have dependency pinned to master in my app

@tute
Copy link
Member

tute commented Jul 23, 2020

Sure! I won't get to these days, but do you think we can do a 4.0.1 release fixing also the original issue you describe? Meaning, do you know how to fix it and can do it before we do the release?

@rwegrzyniak
Copy link
Author

I suppose problem is in removing hook_for :orm, now rails don't know that there is need to run anything under AcitveRecord directory, I can take a look, but I never wrote gem or generator so I don't know where can be problem

@tute
Copy link
Member

tute commented Jul 23, 2020

aha! Then we'd need to readd them, specifying a default of active_record instead of the empty value it was getting (and being improperly taken as a boolean). See https://github.com/merit-gem/merit/pull/349/files

@burmashave
Copy link

I'm confused: if he's running 4.0.0, then hook_for would still be there for him, no?

I just tried running rails g merit:install in several older versions of the gem and it appears that the last time migrations were created was c8c792c, the one before the 'Enable Zeitwork gem mode' commit.

@tute
Copy link
Member

tute commented Jul 23, 2020

I'm confused: if he's running 4.0.0, then hook_for would still be there for him, no?

He was working after 4.0.0 (his latest commit removes it, as he and I had discussed: 622d74f).

Do you know how to send Pull Requests? I can help you if you'd like (or I can try fix it myself in about two weeks).

@burmashave
Copy link

burmashave commented Jul 23, 2020

What I mean is that @rwegrzyniak wouldn't have the hook_for change if he's using 4.0.0 (Jun 2), and that as far as I can tell, the last time rails g merit:install produced migrations was c8c792c.

@rwegrzyniak, if you use in your Gemfile:

gem 'merit', git: 'https://github.com/merit-gem/merit', ref: 'c8c792c'

And then:

bundle update merit
rails g merit:install

... what happens? Does it produce migrations?

@rwegrzyniak
Copy link
Author

When i purged merit files from gem dir, and made ref in Gemfile, then it works without problems

@burmashave
Copy link

@tute - 9f1b6b0 is what caused the change to the generators. Is that what you intended?

Beginning with commit 9f1b6b0

$ rails g merit:install

      create  config/initializers/merit.rb
      create  app/models/merit/badge_rules.rb
      create  app/models/merit/point_rules.rb
      create  app/models/merit/rank_rules.rb

$ rails g merit:active_record:install

      create  db/migrate/20200724160143_create_merit_actions.rb
      create  db/migrate/20200724160144_create_merit_activity_logs.rb
      create  db/migrate/20200724160145_create_sashes.rb
      create  db/migrate/20200724160146_create_badges_sashes.rb
      create  db/migrate/20200724160147_create_scores_and_points.rb

$ rails g merit:active_record:merit user
	(doesn’t work until https://github.com/merit-gem/merit/commit/294fd1253da2361f83b95a0e3f0256d3ec7a4b57)

Previous commit (c8c792c)

$ rails g merit:install

      create    db/migrate/20200724160615_create_merit_actions.rb
      create    db/migrate/20200724160616_create_merit_activity_logs.rb
      create    db/migrate/20200724160617_create_sashes.rb
      create    db/migrate/20200724160618_create_badges_sashes.rb
      create    db/migrate/20200724160619_create_scores_and_points.rb
      create  config/initializers/merit.rb
      create  app/models/merit/badge_rules.rb
      create  app/models/merit/point_rules.rb
      create  app/models/merit/rank_rules.rb

$ rails g merit user

      create    db/migrate/20200724160817_add_merit_fields_to_users.rb
      insert  app/models/user.rb

@younthu
Copy link

younthu commented Aug 3, 2020

same here.

merit 4.0.0.

How should we resolve it?

@tute
Copy link
Member

tute commented Aug 15, 2020

Thanks for your feedback! I just fixed it in master. Please try it out to ensure it works as expected for you too! :)

tute added a commit that referenced this issue Aug 15, 2020
After enabling Zeitwerk mode I unintentionally disabled ORM default
generators (9f1b6b0).

This commit brings them back.

[fixes #351]
tute added a commit that referenced this issue Aug 15, 2020
After enabling Zeitwerk mode I unintentionally disabled ORM default
generators (9f1b6b0).

This commit brings them back.

[fixes #351]
@tute
Copy link
Member

tute commented Aug 15, 2020

@burmashave
Copy link

Works perfectly - thank you!

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

4 participants