Every time I want to add a new gem to a project, I have to open that gem’s documentation. That’s fine…for gems that I just discovered or never used before.
But for gems that I used in several other projects, I’d LOVE if I could just do
rails install <gem_name> group:development and the rest is history.
I don’t remember by heart what’s the exact wording of ActiveAdmin generator or Devise generator, but I used those gems 100s of times and I know exactly what those install generators would do. Here are some different install generators I’ve found (note that most (but not all) are similar/the same). Convention over Configuration would really help unify this:
Gem name | Install generator
activeadmin | rails generate active_admin:install (underscore)
devise | rails generate devise:install (looks good!)
rolify | rails g rolify Role User (no
:install, could use defaults or be interactive)
actiontext | rails action_text:install (no generate here, underscore)
delayed_job_active_record | rails generate delayed_job:active_record
cancancan | rails g cancan:ability
We can see that most of the gems gravitate around similar idea, but quite a big number of them do it their own way.
I think rails could replace this “Documentation over Configuration” with Convention over Configuration and introduce
rails install command which will: add gem to Gemfile and run install generator if there is one that’s defined according to some rules (for example:
It could also run migrations or that could be optional.