2013-11-22 38 views
7

我在写一个Rails engine的过程,但我不知道如何延长我的配置/ application.rb中Rails的发动机延伸的config/application.rb中

我想我必须让应用程序名称莫名其妙 有什么想法?

require File.expand_path('../boot', __FILE__) 

require 'rails/all' 

# Require the gems listed in Gemfile, including any gems 
# you've limited to :test, :development, or :production. 
Bundler.require(:default, Rails.env) 

module application_name 
    class Application < Rails::Application 
    end 
end 
+0

您可以举一个例子来说明您想要做什么样的“扩展”? – midu

回答

2

对于--full和--mountable引擎

这会为您生成。

module engine_name 
    class Engine < ::Rails::Engine 
    end 
end 

在你的主要应用的Gemfile添加

gem 'engine_name', path: "/path/to/engine_name"

而在你的应用程序的config/routes.rb中文件

mount engine_name::Engine, at: "/<mount_point_you_choose>"

http://guides.rubyonrails.org/engines.html

采取˚F rom上面的链接...

--mountable选项告诉生成器,您要创建一个“可挂载”和命名空间隔离的引擎。该发电机将提供相同的骨架结构将在--full选项,并会增加:

资产清单文件(的application.js和application.css) 一个命名空间的ApplicationController存根 一个命名空间ApplicationHelper存根 布局视图引擎模板 将命名空间隔离到config/routes.rb: