Rails EngineAn awesome tool to extend your rails application               Muntasim Ahmed   Platform Architect @ Tasawr In...
Agenda•   Why Rails Engine•   What is Rails Engine•   How it works with Rails Core•   Who are they•   Where is your interest
Problems• Large application without reusable component• Slow testing ( if any :) )• Larger app, messy
Solution• Find common functionalities• Extract them to module => Gems• Use railtie to tie with Rails App => Rails Engine
One Thing!Rails (version>=3.1) is just a “supercharged” engine               http://edgeguides.rubyonrails.org/engines.html
Rails Engine ?• pre-packaged application• able to be run or mounted within another Rails  application• can have its own mo...
Rails Engine ?•
Rails Engine has      Image source: Railscasts.com
Rails Engine has     Image source: Google
Rails Engine has        Image source: Google
Rails Engine has         Image source: Google
Rails engine walk-through•   Create an engine•   Implement requirements in app, lib etc.•   Test•   Mount to main app•   O...
Rails engine walk-throughCreaterails plugin new awesome_engine --mountableThen generate mvc stuffs, testIn App Gemfilegem ...
Rails engine walk-throughHit localhost:3000/awesome_engine_path                                    (mount point)It will hi...
Rails engine walk-throughRoutes:Use engine routes from main app usingengine_name.route_namee.g.   awesome_name.root_path
Rails engine walk-throughRoutes:Use main app routes from engine usingmain_app.route_namee.g. main_app.root_path
Who are they•   Rails Admin•   Devise•   Blogit•   Tolk•   .....
References•   http://railscasts.com/episodes/277-mountable-engines•   http://www.slideshare.net/AndyMaleh/rails-engine-pat...
Thanks for your attention :)
???Question(s)
Upcoming SlideShare
Loading in …5
×

Rails Engine :: modularize you app

1,838 views

Published on

It contains rails engine basics, and answers of some wh question regarding rails engine

Published in: Technology
3 Comments
1 Like
Statistics
Notes
No Downloads
Views
Total views
1,838
On SlideShare
0
From Embeds
0
Number of Embeds
1
Actions
Shares
0
Downloads
20
Comments
3
Likes
1
Embeds 0
No embeds

No notes for slide

Rails Engine :: modularize you app

  1. 1. Rails EngineAn awesome tool to extend your rails application Muntasim Ahmed Platform Architect @ Tasawr Interactive https://github.com/railscash muntasim@tasawr.com
  2. 2. Agenda• Why Rails Engine• What is Rails Engine• How it works with Rails Core• Who are they• Where is your interest
  3. 3. Problems• Large application without reusable component• Slow testing ( if any :) )• Larger app, messy
  4. 4. Solution• Find common functionalities• Extract them to module => Gems• Use railtie to tie with Rails App => Rails Engine
  5. 5. One Thing!Rails (version>=3.1) is just a “supercharged” engine http://edgeguides.rubyonrails.org/engines.html
  6. 6. Rails Engine ?• pre-packaged application• able to be run or mounted within another Rails application• can have its own models, views, controllers, generators and publicly served static files
  7. 7. Rails Engine ?•
  8. 8. Rails Engine has Image source: Railscasts.com
  9. 9. Rails Engine has Image source: Google
  10. 10. Rails Engine has Image source: Google
  11. 11. Rails Engine has Image source: Google
  12. 12. Rails engine walk-through• Create an engine• Implement requirements in app, lib etc.• Test• Mount to main app• Override where necessary• And done!
  13. 13. Rails engine walk-throughCreaterails plugin new awesome_engine --mountableThen generate mvc stuffs, testIn App Gemfilegem "awesome_engine", path => "awesome_engine_pathIn App Routemount AwesomeEngine::Engine => "/awesome_engine_path", as =>“awesome_engine"
  14. 14. Rails engine walk-throughHit localhost:3000/awesome_engine_path (mount point)It will hit engines root path Welcome to awesome engine home!
  15. 15. Rails engine walk-throughRoutes:Use engine routes from main app usingengine_name.route_namee.g. awesome_name.root_path
  16. 16. Rails engine walk-throughRoutes:Use main app routes from engine usingmain_app.route_namee.g. main_app.root_path
  17. 17. Who are they• Rails Admin• Devise• Blogit• Tolk• .....
  18. 18. References• http://railscasts.com/episodes/277-mountable-engines• http://www.slideshare.net/AndyMaleh/rails-engine-patterns• http://www.slideshare.net/mirrec/rails-engine-rubyslava• http://edgeguides.rubyonrails.org/engines.html• http://edgeapi.rubyonrails.org/classes/Rails/Engine.html• http://pivotallabs.com/users/shagemann/blog/articles/1994- migrating-rom-a-single-rails-app-to-a-suite-of-rails-engines Image source: Google, Railscasts and Dulal Khan
  19. 19. Thanks for your attention :)
  20. 20. ???Question(s)

×