<commit_before>---
layout: post
title: Make Engines
---
In [previous post]({{ site.baseurl }}/Ruby:-Make-Gems-with-Bundler/) I discuessed ruby gem creation.  
In this post I will expound on creation of Rails engines - a variant of ruby gem that assumes inclusion in a rails app and, usually, provides functionality through models/controllers.  
Assumptions: Namespaced, RSpec+FactoryBot, Postgres (at least in dev).  

See also [this post](https://www.viget.com/articles/rails-engine-testing-with-rspec-capybara-and-factorygirl/).

### 1. Init engine project

```
# rvm install ruby-<version>
rvm install ruby-2.3.7

# rvm use 2.3.7@<gemset> --create
rvm use 2.3.7@myengine --create

gem install bundler

# gem install rails -v <version>
gem install rails -v 4.2.10

# make a directory that matches your intended engine name
mkdir ~/code/myengine
cd ~/code/myengine

# run the opinionated initializer, will use spec/dummy for test app and Postgres database
rails plugin new . --mountable --dummy-path=spec/dummy -T --skip-bundle --database=postgresql
```<commit_msg>Bettered engine setup post2<commit_after>---
layout: post
title: Make Engines
---
In [previous post]({{ site.baseurl }}/Ruby:-Make-Gems-with-Bundler/) I discuessed ruby gem creation.  
In this post I will expound on creation of Rails engines - a variant of ruby gem that assumes inclusion in a rails app and, usually, provides functionality through models/controllers.  
Assumptions: Namespaced, RSpec+FactoryBot, Postgres (at least in dev).  

See also [this post](https://www.viget.com/articles/rails-engine-testing-with-rspec-capybara-and-factorygirl/).
And also a [simple setup writeup](http://www.andrewhavens.com/posts/27/how-to-create-a-new-rails-engine-which-uses-rspec-and-factorygirl-for-testing/).

### 1. Init engine project

```
# rvm install ruby-<version>
rvm install ruby-2.3.7

# rvm use 2.3.7@<gemset> --create
rvm use 2.3.7@myengine --create

gem install bundler

# gem install rails -v <version>
gem install rails -v 4.2.10

# make a directory that matches your intended engine name
mkdir ~/code/myengine
cd ~/code/myengine

# run the opinionated initializer, will use spec/dummy for test app, Postgres database, and a mountable (as in namespaced) engine.
rails plugin new . --mountable --dummy-path=spec/dummy -T --skip-bundle --database=postgresql
```
{'fraction_non_alphanumeric': 0.11799914493373237, 'fraction_numerical': 0.013253527148353997, 'mean_word_length': 4.010706638115631, 'pattern_counts': {'":': 0, '<': 9, '<?xml version=': 0, '>': 9, 'https://': 2, 'lorem ipsum': 0, 'www.': 3, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '4542131', 'n_tokens_mistral': 787, 'n_tokens_neox': 737, 'n_words': 259}