Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How do I pass `rails new` flags from my Rails template

Rails application templates sound great, and I want to create my own custom template instead of repeating myself to create a common base for every single application I create.

How do I run the equivalent of rails new --api --webpack=react --database=postgresql from inside my template so that it automatically does this when I run rails new myapp -m http://example.com/template.rb

like image 542
Amin Shah Gilani Avatar asked Dec 08 '25 08:12

Amin Shah Gilani


1 Answers

You don't. Application template is applied after rails app is already generated.

What you can do is overwrite some files/lines in your application template (replace database.yml, etc.). Or just add those flags in the rails new command, along with your template parameter.

If you want to always create apps with those flags, just put them in the .railsrc file and they'll be picked up automatically.

~/.railsrc

--api 
--webpack=react 
--database=postgresql
like image 74
Sergio Tulentsev Avatar answered Dec 09 '25 23:12

Sergio Tulentsev