-
Notifications
You must be signed in to change notification settings - Fork 19
Create an Engine
afmelo edited this page Dec 3, 2014
·
12 revisions
rails plugin new vendor/engines/[engine_name] --full
require 'weby'
::Weby::registe_extension(Weby::Extension.new(:engine_name, author: 'Cercomp - Equipe Web', settings: [:text]))
In engine_name folder, open engine.rb file (in lib/engine_name)
module engine_name
class Engine < ::Rails::Engine
mod = engine_name
engine_name(generate_railtie_name(mod.name))
self.routes.default_scope = {}
self.isolated = true
unless mod.respond_to?(:railtie_namespace)
name, railtie = engine_name, self
mod.singleton_class.instance_eval do
define_method(:railtie_namespace) { railtie }
unless mod.respond_to?(:table_name_prefix)
define_method(:table_name_prefix) { "#{name}_" }
end
unless mod.respond_to?(:use_relative_model_naming?)
class_eval "def use_relative_model_naming?; true; end", __FILE__, __LINE__
end
end
end
To define routes, create a routes.rb file in vendor/engines/[engine_name]/lib/[engine-name]