Rails Application Template for Creating Ruby-on-Rails Apps

How can you save your time when developing a rails application? The answer is to use application templates you can build on the basis of simple template our team has recently created. We believe it can be really helpful in your every-day development practice.

What is Rails Application Template?

Rails Application Template is a basic template for creating Ruby-on-Rails applications. It simplifies the development process when starting a new project and saves your time which can be spent more wisely. Thereby, you can omit all the routine actions and skip to the stages that require you to be more creative and apply your professional skills.

Advantages:

  • Time-saving. As we've already mentioned, our template saves you from unnecessary work and allows to switch your attention to more interesting tasks.
  • Easy process of configuring rails gems. You can easily configure our template to fit your needs and add new gems (below, we're describing this process in more details).
  • Ease of use. This template is really easy-to-use and can be enhanced for your own requirements in a straightforward manner.

How to use

First of all, you should download or clone the template. Then set your ruby version and gemset:

$ rvm use 2.3.0@myapp --create

When it’s done, install rails gem for the gemset:

$ gem install rails -v 'your_rails_version'

Now you’re ready to use our template when creating your application:

$ rails new myapp -m /path/to/template/bootstrap.rb

That’s all! It was quite easy, right? And now you can enjoy your application!

Customization

The template uses config.yml file for installing and configuring rails gems and other stuff. Below you can find a list of statements able to help you customize your own template.

1) The configuration file consists of several blocks dividing the application generation process into some logic parts.

rvm: ...
testing: ...
documentation: ...
deploy: ...

2) The main part of each block is gems. So if you want to have more gems in your project just add a new block with a name that corresponds with your appropriate gems block or add your gems to any existing block.

testing:
  gems:
    faker: true
    rspec-rails:
      group: test, development
    factory_girl_rails:
      version: ~> 4.8
      group: test, development

You can use a true value for a gem that in this case will be added to Gemfile as gem 'faker'

You can also pass version and/or group params and they will be used in Gemfile:

gem 'factory_girl_rails', '~> 4.8', group: [:test, :development]

3) Each block can run its own runner from runners folder if one exists. There you can put any code you want to execute, i.e.

create_file '.ruby-version', RUBY_VERSION
create_file '.ruby-gemset', app_name
file '.rvmrc', "rvm use #{RUBY_VERSION}@#{app_name}"

4) If you want to perform some actions after gem is added, i.e. run rails generate rspec:install, put callback to the runner and it will be executed when you need. By convention, callback name depends on gem name and should look like:

"#{your_gem_name.gsub('-', '_')}_callback"

So the full configuration for rspec-rails looks like:

# config.yml
testing:
 gems:
   rspec-rails:
     group: test, development

# runners/testing.rb
def rspec_rails_callback
 generate('rspec:install')
end

You can also read our description of this project here.

 

Rate this article
0 ratings, average 0.00 of out 5
Table of contents
Get in touch
Related articles
Effective Layout Testing Tools
Effective Layout Testing Tools

QA/QC

5 min read

jQuery GTM In-Viewport Manager Plugin
jQuery GTM In-Viewport Manager Plugin

Development

1 min read

Blockchain Myths Debunked: Separating Fact from Fiction
Blockchain Myths Debunked: Separating Fact from Fiction

Blockchain

5 min read

Effective Layout Testing Tools
Effective Layout Testing Tools

QA/QC

5 min read

jQuery GTM In-Viewport Manager Plugin
jQuery GTM In-Viewport Manager Plugin

Development

1 min read