You can find some very useful rails templates to generate boiler plate codes in your Rails app. You can send Pull Requests for some useful templates that can be useful for others as well.
- Examples
You can use these templates on already existing application as well.
This will do the following
-
Add gems
rspec,slim-rails,annotate,zeus,pry,rspec-rails,faker,database_cleaner,factory_girl_rails,shoulda-matchersandrails-controller-testingto your Gemfile.Note: But this will not add twice, it will add only if there is not already.
Will add necessary config files to
spec/support/for above mentioned gems to be used intest-mode. Will install thebundleand install RSpec as well.
$ rails app:template LOCATION=https://raw.githubusercontent.com/shivabhusal/useful_rails_templates/master/test_template.rb
# Short Form
$ rails app:template LOCATION=https://goo.gl/f6P7ne app_setup=trueMake sure you are on root directory of your application.
This is pretty useful when you generated your app without specifying -d=database_name, Rails configure your app with
sqlite3, but your requirement is mysql. Or, you were knowingly using mysql but needed to move to pg.
How to get the initial database.yml file so that you can modify it?
$ rails app:template LOCATION=https://raw.githubusercontent.com/shivabhusal/useful_rails_templates/master/database_template.rb db=mysql
# Short Form
$ rails app:template LOCATION=https://goo.gl/9s8NV6 db=mysql$ rails app:template LOCATION=https://raw.githubusercontent.com/shivabhusal/useful_rails_templates/master/database_template.rb db=pg
# Short form
$ rails app:template LOCATION=https://goo.gl/9s8NV6 db=pg$ rails app:template LOCATION=https://raw.githubusercontent.com/shivabhusal/useful_rails_templates/master/database_template.rb db=sqlite
# Short form
$ rails app:template LOCATION=https://goo.gl/9s8NV6 db=sqliteWill add gem premailer-rails to Gemfile and set config in config/application.rb.
Use command
$ rails app:template LOCATION=https://raw.githubusercontent.com/shivabhusal/useful_rails_templates/master/mailer_template.rb
# Short Form
$ rails app:template LOCATION=https://goo.gl/iG8NS9 mailer=trueUse command
$ rails app:template LOCATION=https://raw.githubusercontent.com/shivabhusal/useful_rails_templates/master/figaro_template.rb
# Short Form
$ rails app:template LOCATION=https://goo.gl/BVvfZb figaro=trueUse command
$ rails app:template LOCATION=https://raw.githubusercontent.com/shivabhusal/useful_rails_templates/master/gitignore_template.rb
# Short Form
$ rails app:template LOCATION=https://goo.gl/ukw7zK gitignore=true