Run:
$ rails plugin new <name>
To generate a isolated engine use --mountable
The .rb file generated in folder lib
should have the same name of the gem, otherwise it will not load automatically.
To more informatiation run: $ rails plugin new --help