[Feature request] `rails install`

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
2 messages Options
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

[Feature request] `rails install`

Viktor Fonic
# originally posted at: https://github.com/rails/rails/issues/29647

Whenever I want to add a gem to my rails app, I go to specific gem's github repo and follow the Readme instructions. Usually there are couple of steps to install the gem:

1. Add the gem to your Gemfile
 * This is almost always the same - possible config options could be: `require: false` or `group :development, :test`
2. Run the gem's generator
 * Usually `rails generate gem_name:install` or `rake gem_name:install:migrations`
3. Migrate the database

I have an idea that would streamline this process and make it easier to add gem to rails apps:
`rails install` command

This command would install a ruby gem and run any necessary generators and setup code to make the gem fully installed and added to the app.
There are many times when I know the exact name of the gem but I can't remember [how](https://github.com/rspec/rspec-rails#installation) | [to](https://github.com/thoughtbot/factory_girl_rails#configuration) | [install](https://github.com/norman/friendly_id/#rails-quickstart) | [the](https://github.com/RubyMoney/money-rails#installation) | [gem](https://github.com/bokmann/font-awesome-rails#usage) | [correctly](https://github.com/mbleigh/acts-as-taggable-on#post-installation). Note that every one of these gems has different installation process, although all of these steps in all of these gems can be automatically executed (with sensible defaults that can be changed through cli arguments). Those gems that require more customization (for example: creating migration to add fields to existing models), could output that info right in the console after the installation (something similar to post-install gem message, but displayed every time after `rails install` command, not only when installing gem for the first time.

Rails is all about Convention-over-Configuration. What we lack here is Convention.

Gem developers could add a simple config option (e.g. in .gemspec file) or dotfile to their gems that will set the flag that this gem follows (new) rails gem installation configuration. Then we could define the necessary instructions to fully install and setup the gem. It could work similarly to `rails new` template.
[Devise](https://github.com/plataformatec/devise) does something like this already for their install generator:
https://github.com/plataformatec/devise/blob/master/lib/generators/devise/install_generator.rb#L35
https://github.com/plataformatec/devise/tree/master/lib/generators/templates

This idea comes from `ember install`:
https://github.com/ember-cli/ember-cli#install-an-ember-cli-addon

--
You received this message because you are subscribed to the Google Groups "Ruby on Rails: Core" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
To post to this group, send email to [hidden email].
Visit this group at https://groups.google.com/group/rubyonrails-core.
For more options, visit https://groups.google.com/d/optout.
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

[Feature request] `rails install`

matrix9180
This seems like something that would be best developed with the rubygems / bundler projects as a lot of gems support more than just Rails projects. Each project that requires more setup than a line in a gemfile would have to adopt this and support it, or that project / rails itself could be perceived as "broken" when 'rails install' doesn't work. Seems like a lot of effort to save 30 seconds of reading and following setup instructions.

--
You received this message because you are subscribed to the Google Groups "Ruby on Rails: Core" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
To post to this group, send email to [hidden email].
Visit this group at https://groups.google.com/group/rubyonrails-core.
For more options, visit https://groups.google.com/d/optout.
Loading...