2016-05-17 105 views
-1

我已經創建了一個新的rails 4引擎,並嘗試爲新創建的引擎工作沒有安裝路線,但它在下面沒有爲我工作的文件。Rails 4引擎沒有加載根路線的路線

應用程序/ routes.rb中(根路由文件)

Rails.application.routes.draw do 
    mount Uhoh::Engine => "/uhoh" 
    resources :products 
end 

NEW_ENGINE /配置/ routes.rb中(發動機路由文件)

Uhoh::Engine.routes.draw do 
    get "failures#index" 
end 

uhoh/LIB/uhoh/engine.rb(引擎文件)

module Uhoh 
    class Engine < ::Rails::Engine 
    isolate_namespace Uhoh 
    end 
end 

,但是當我遇到來自treminal「回扣路線」命令,則它不會顯示從「Uhoh」演義路線東北。

Prefix Verb URI Pattern     Controller#Action 
     uhoh  /uhoh      Uhoh::Engine 
    products GET /products(.:format)   products#index 
      POST /products(.:format)   products#create 
new_product GET /products/new(.:format)  products#new 
edit_product GET /products/:id/edit(.:format) products#edit 
    product GET /products/:id(.:format)  products#show 
      PATCH /products/:id(.:format)  products#update 
      PUT /products/:id(.:format)  products#update 
      DELETE /products/:id(.:format)  products#destroy 

Routes for Uhoh::Engine: 
+0

是在'uhoh /配置/ routes.rb'您Uhoh路線文件? – etdev

+0

是的,它是在uhoh/config/routes.rb – user3906755

回答

2

$ Rails插件新blorgh --mountable 的應用程序目錄樹 一個配置/ routes.rb中文件: 在LIB/blorgh/engine.rb,A文件,該文件是在功能上相同的標準的Rails應用程序的config/application.rb中的文件: 模塊Blorgh 類引擎< ::滑軌::引擎 結束 結束

的--mountable選項將添加到--full選項:

資產清單文件(的application.js和application.css) 一個命名空間的ApplicationController存根 一個命名空間ApplicationHelper存根 發動機 命名空間隔離的佈局視圖模板到config/routes.rb中:

Blorgh ::引擎。 routes.draw做 結束

命名空間隔離的lib/blorgh/engine.rb:

模塊blorgh 類引擎< ::滑軌::引擎 isolate_namespace blorgh 端 端

此外,--mountable選項告訴發生器安裝通過將以下的僞應用程序的路由位於測試/虛設虛設測試應用程序內的發動機文件在測試/虛設/配置/路由.RB:

安裝blorgh ::引擎=> 「/ blorgh」

應用程序/控制器/ blorgh/articles_controller.rb:

require_dependency 「blorgh/application_controller」

模塊Blorgh 類ArticlesController < ApplicationController的 ... 結束 結束

+0

我遵循相同的文件,但爲什麼我的路線不能從我的根應用程序文件夾? – user3906755