Ruby on Rails mountable vs. full Engine

Source: Internet
Author: User
Tags ruby on rails

Original: https://www.travisluong.com/ruby-on-rails-mountable-vs-full-engine/
A rails Engine is essentially a rails application that you can attach to other rails application to provide additional functionality.
A rails engine is a rails application because it follows the same model view controller pattern as the "normal" rails application.

What's the difference between rails engine and the usual rails application, a rails engine typically uses commands, $ rails plugin new my_engine--mountable or Rails plugin n EW My_engine--full Generation,

Because engines is packaged as a ruby gems, when you use the required gems, you add them in Gemspec instead of gemfile, and when you use bundler, the Gemfile function in Gemspec will automatically load them, So you have to use require to introduce them in engine.rb, otherwise you will see Nomethod errors, and a virtual application will be generated in your test directory, used for testing, you must copy the entire migrated file into your virtual application, and any Looking to use this engine of the appliction, fortunately, the engine has a rake command can do this thing, rake my_engine:install:migrations

The main difference between the two types is that the mountable engine has a separate namespace, and the full engine does not, which means that mountable engine can run as part of the host application, and the full engine Must be integrated into host applicatin, in essence, a full engine shares models views, controllers, helpers and routes with host application, a mountable Engine does not share, mountable engine has its own layout,javascript, CSS files, and full engine is not, use mountable engine need in your host The application route file is mounted to a sub-path using the Mount function, but the full engine does not look like a ountable engine for a single application, such as Blog,forum, a full Engine suitable for adding to an existing application such as authentication scheme, or permission interface, mountable engine suitable for use with application, full engine for use with application

Ruby on Rails mountable vs. full Engine

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.