2. Namaste! - Sushil Shrestha
2y PSD + 1.5y HTML/CSS/JS + 1.5... y ROR
An enthusiastic start and a clean finish as my goal,
@sushil10018
http://jyaasa.comCopyright 2016. Jyaasa Technologies.
3. Maintain DRY within multiple apps
Easy upgrade when required
Reusable pieces of code
Quick Development
Separate Tests
1.
Why Engine?
7. “The details are details. They make the
product. The connections, the connections,
the connections. It will in the end be these
details that give the product its life.
http://jyaasa.comCopyright 2016. Jyaasa Technologies.
▸Charles Eames
9. http://jyaasa.comCopyright 2015. Jyaasa Technologies.
2.1
Process
to start engine
Generate Engine
$ rails plugin new <nicengine> --mountable
The --mountable option tells the generator that you
want to create a "mountable" and namespace-
isolated engine.
Namespace::TheMagic
-model, table_names, controller, views, mailers
-routes
-app directory: subdirectory for each namespace
-assets, controllers, views
-bin directory:
-the rails sub-commands used from within this will be
namescoped as well.
-test directory:
10. http://jyaasa.comCopyright 2015. Jyaasa Technologies.
2.3
Mount
engine in App
Integrate Engine
$ gem nicengine, path: "/path/to/nicengine"
by placing the gem in the Gemfile it will be loaded
when Rails is loaded
$ mount in application’s config/routes.rb
mount Nicengine::Engine, at: "/wherever"
=> http://localhost:3000/wherever
$ rake nicengine:install:migrations
copies the migration from engine to app
$ to override
create specific files in the same namespaced path
as it is by the engine like:
thepact/app/models/concerns/spree/
user_payment_source.rb
12. Mini Rails Application
Can be mounted over host application
Lives being namespaced & modular3.1
Everything
can be an engine
13. ●Getting Started with Engines:
http://guides.rubyonrails.org/engines.html
●Clearer Picture:
http://tech.taskrabbit.com/blog/2014/02/11/rails-4-engines/
●Depth:
http://api.rubyonrails.org/classes/Rails/Engine.html
●How to Build a Rails Engine:
http://brandonhilkert.com/blog/how-to-build-a-rails-engine/
http://jyaasa.comCopyright 2015. Jyaasa Technologies.
4.
Resources
learning is endless
14. Thank you, for
bearing me!
Any Queries?
Find me at www.sushil10018.com.
Feel free to contact me through any medium, I
always love to talk.
http://jyaasa.comCopyright 2015. Jyaasa Technologies.
fb.com/brokenmuskan
twitter.com/sushil10018
github.com/sushil10018