merit-gem/merit

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

rwegrzyniak opened this issue · 18 comments

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

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

tute commented

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

I'm using 4.0.0 from rubygems

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 commented

That last one is fixed in master: 294fd12

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 commented

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?

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 commented

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

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 commented

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).

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?

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

@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

same here.

merit 4.0.0.

How should we resolve it?

tute commented

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

Works perfectly - thank you!