Skip to content
Craig Kaminsky edited this page Jul 26, 2014 · 6 revisions

Welcome

Here you will find what little you need to know about the Rails Service Generator gem.

RailsServices

A very simple gem for Rails that adds a generator for easily creating a service class and its accompanying spec file.

At this time, the gem only creates an RSpec test file. MiniTest and Test::Unit support forthcoming.

Requirements

Rails 3.2.19 and higher

Installation

Add this line to your application's Gemfile:

gem 'rails_services'

And then execute:

$ bundle

Or install it yourself as:

$ gem install rails_services

Usage

$ rails generate rails_services:create Service Model|Controller Sub-folder^

$ rails generate rails_services:destroy Service Model|Controller Sub-folder^

^Sub-folders are optional but, at this time, you may only use one sub-folder. I generally use the sub-folders when I have a naturally grouped set of services.

Result

Two files are created:

  • app/services/model|controller/[sub-folder]/thing.rb
  • spec/services/model|controller/[sub-folder]/thing_spec.rb
Clone this wiki locally