merit-gem / merit

Reputation engine for Rails apps
Other
1.53k stars 197 forks source link

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

Closed rwegrzyniak closed 4 years ago

rwegrzyniak commented 4 years ago

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

rwegrzyniak commented 4 years ago

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

tute commented 4 years ago

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

rwegrzyniak commented 4 years ago

I'm using 4.0.0 from rubygems

rwegrzyniak commented 4 years ago

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 4 years ago

That last one is fixed in master: https://github.com/merit-gem/merit/commit/294fd1253da2361f83b95a0e3f0256d3ec7a4b57

rwegrzyniak commented 4 years ago

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 4 years ago

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 commented 4 years ago

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 4 years ago

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 commented 4 years ago

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 https://github.com/merit-gem/merit/commit/c8c792c368980cf670feceb7b1d259e77035f473, the one before the 'Enable Zeitwork gem mode' commit.

tute commented 4 years ago

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: https://github.com/merit-gem/merit/commit/622d74f4f14e3de2350cb90a2c4a51939abf4295).

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 commented 4 years ago

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 https://github.com/merit-gem/merit/commit/c8c792c368980cf670feceb7b1d259e77035f473.

@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 commented 4 years ago

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

burmashave commented 4 years ago

@tute - https://github.com/merit-gem/merit/commit/9f1b6b0089b47e188018c7e1725db43842ae6586 is what caused the change to the generators. Is that what you intended?

Beginning with commit https://github.com/merit-gem/merit/commit/9f1b6b0089b47e188018c7e1725db43842ae6586

$ 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 (https://github.com/merit-gem/merit/commit/c8c792c368980cf670feceb7b1d259e77035f473)

$ 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 commented 4 years ago

same here.

merit 4.0.0.

How should we resolve it?

tute commented 4 years ago

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

tute commented 4 years ago

Released merit 4.0.1 with this fix:

burmashave commented 4 years ago

Works perfectly - thank you!