包含已安装模块引擎路由的Rails应用程序路由

时间:2017-09-19 09:48:43

标签: ruby-on-rails rubygems

的routes.rb

Blog::Application.routes.draw do

  mount Helpdesk::Engine, :at => '/helpdesk'

  get '/search/index' => 'search#index', as: :search_index

end

服务台/ ticket_controller.rb

module Helpdesk
 class TicketsController < Helpdesk::ApplicationController

 before_filter :ensure_user
 helper TicketsHelper

# GET /tickets
# GET /tickets.json
def index
  if params[:tickets] == 'closed'
    @tickets = Helpdesk::Ticket.where(:requester_id => helpdesk_user.id).closed.page(params[:page])
  else
    @tickets = Helpdesk::Ticket.where(:requester_id => helpdesk_user.id).active.page(params[:page])
  end


  respond_to do |format|
    format.html # index.html.erb
    format.json { render json: @tickets }
  end
 end
end

视图/服务台/车票/ index.html.erb

<html>
 <head></head>
 <body>
  <ul class="nav navbar-nav navbar-right dash-nav">
   <li>
     <%= link_to 'search', search_index_path %>
   </li>
  </ul>
  </body>
</html>

生成以下错误:

#&lt;#:0x007fe689b2fc60&gt;

的未定义局部变量或方法`search_index_path'

佣金路线的结果:

   Prefix Verb          URI Pattern                  Controller#Action

   helpdesk            /helpdesk                     Helpdesk::Engine

   search_index GET      /search/index(.:format)     search#index

   root GET       /      pages#home

   home GET       /home(.:format)     pages#home

   inside GET       /inside(.:format)           pages#inside

   new_user_session GET       /users/sign_in(.:format)  devise/sessions#new

  user_session POST      /users/sign_in(.:format)                  devise/sessions#create

  destroy_user_session DELETE    /users/sign_out(.:format)       devise/sessions#destroy



   Routes for Helpdesk::Engine:

   assign_admin_ticket GET    (/:locale)/admin/tickets /:id/assign(.:format)    helpdesk/admin/tickets#assign {:locale=>/pl|pt|en/}

         admin_tickets GET    (/:locale)/admin/tickets(.:format)               helpdesk/admin/tickets#index {:locale=>/pl|pt|en/}

                       POST   (/:locale)/admin/tickets(.:format)               helpdesk/admin/tickets#create {:locale=>/pl|pt|en/}

      new_admin_ticket GET    (/:locale)/admin/tickets/new(.:format)           helpdesk/admin/tickets#new {:locale=>/pl|pt|en/}

     edit_admin_ticket GET    (/:locale)/admin/tickets/:id/edit(.:format)      helpdesk/admin/tickets#edit {:locale=>/pl|pt|en/}

          admin_ticket GET    (/:locale)/admin/tickets/:id(.:format)           helpdesk/admin/tickets#show {:locale=>/pl|pt|en/}

                       PATCH  (/:locale)/admin/tickets/:id(.:format)           helpdesk/admin/tickets#update {:locale=>/pl|pt|en/}

                       PUT    (/:locale)/admin/tickets/:id(.:format)           helpdesk/admin/tickets#update {:locale=>/pl|pt|en/}

                       DELETE (/:locale)/admin/tickets/:id(.:format)           helpdesk/admin/tickets#destroy {:locale=>/pl|pt|en/}

    admin_ticket_types GET    (/:locale)/admin/ticket_types(.:format)          helpdesk/admin/ticket_types#index {:locale=>/pl|pt|en/}

                       POST   (/:locale)/admin/ticket_types(.:format)          helpdesk/admin/ticket_types#create {:locale=>/pl|pt|en/}

 new_admin_ticket_type GET    (/:locale)/admin/ticket_types/new(.:format)      helpdesk/admin/ticket_types#new {:locale=>/pl|pt|en/}

edit_admin_ticket_type GET    (/:locale)/admin/ticket_types/:id/edit(.:format) helpdesk/admin/ticket_types#edit {:locale=>/pl|pt|en/}

     admin_ticket_type GET    (/:locale)/admin/ticket_types/:id(.:format)      helpdesk/admin/ticket_types#show {:locale=>/pl|pt|en/}

                       PATCH  (/:locale)/admin/ticket_types/:id(.:format)      helpdesk/admin/ticket_types#update {:locale=>/pl|pt|en/}

                       PUT    (/:locale)/admin/ticket_types/:id(.:format)      helpdesk/admin/ticket_types#update {:locale=>/pl|pt|en/}

                       DELETE (/:locale)/admin/ticket_types/:id(.:format)      helpdesk/admin/ticket_types#destroy {:locale=>/pl|pt|en/}

帮助台引擎外部的所有路径(如home,new_user_signin,user_session_destroy)未定义在helpdesk / tickets / index.html.erb,

所以我想知道将应用程序路由包含到已安装的引擎

0 个答案:

没有答案