1

まず、事実:

localhost:3000 / Engageに移動すると、次のエラーが発生します。

ActionController::RoutingError at /
No route matches {:controller=>"engage/home"}

エラー画像

これが私のroutes.rbファイルです:

Kt::Application.routes.draw do

  #resources :authentications


  resources :paths


  mount Engage::Engine => '/engage', :as => 'engage'

  resources :comments do
    member {post :forresource}
  end


  resources :resources do
      member { post :vote }
      collection {get :search}
    end

  devise_for :users

  resources :userResourceView
  resources :learningPaths
  get "home/index"
  devise_scope :user do
    get "/login" => "devise/sessions#new"

  end
  devise_for :user, :path => '', :path_names => {:sign_up => "register" }

  match '/user_profile', :to =>'users#index'
  get 'tags/:tag', to: 'resources#index', as: :tag

  match '/auth/:provider/callback' => 'authentications#create'
  match '/auth/:provider/failure', :to => 'authentications#failure'
  #match '/auth/:provider/callback?error_reason...', :to => 'profiles#failure'

  match '/resources', to: 'resources#create', :via => :post
  match 'contact' => 'contact#new', :as => 'contact', :via => :get
  match 'contact' => 'contact#create', :as => 'contact', :via => :post
  match '/forums' => 'forums#index'

  root to: 'home#index', :as => :home

レーキルートを実行すると、次のようになります。

155-99-191-20:KnowledgeThief dainewinters$ rake routes
                   paths GET    /paths(.:format)                     paths#index
                         POST   /paths(.:format)                     paths#create
                new_path GET    /paths/new(.:format)                 paths#new
               edit_path GET    /paths/:id/edit(.:format)            paths#edit
                    path GET    /paths/:id(.:format)                 paths#show
                         PUT    /paths/:id(.:format)                 paths#update
                         DELETE /paths/:id(.:format)                 paths#destroy
                  engage        /engage                              Engage::Engine
     forresource_comment POST   /comments/:id/forresource(.:format)  comments#forresource
                comments GET    /comments(.:format)                  comments#index
                         POST   /comments(.:format)                  comments#create
             new_comment GET    /comments/new(.:format)              comments#new
            edit_comment GET    /comments/:id/edit(.:format)         comments#edit
                 comment GET    /comments/:id(.:format)              comments#show
                         PUT    /comments/:id(.:format)              comments#update
                         DELETE /comments/:id(.:format)              comments#destroy
           vote_resource POST   /resources/:id/vote(.:format)        resources#vote
        search_resources GET    /resources/search(.:format)          resources#search
               resources GET    /resources(.:format)                 resources#index
                         POST   /resources(.:format)                 resources#create
            new_resource GET    /resources/new(.:format)             resources#new
           edit_resource GET    /resources/:id/edit(.:format)        resources#edit
                resource GET    /resources/:id(.:format)             resources#show
                         PUT    /resources/:id(.:format)             resources#update
                         DELETE /resources/:id(.:format)             resources#destroy
        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
           user_password POST   /users/password(.:format)            devise/passwords#create
       new_user_password GET    /users/password/new(.:format)        devise/passwords#new
      edit_user_password GET    /users/password/edit(.:format)       devise/passwords#edit
                         PUT    /users/password(.:format)            devise/passwords#update
cancel_user_registration GET    /users/cancel(.:format)              devise/registrations#cancel
       user_registration POST   /users(.:format)                     devise/registrations#create
   new_user_registration GET    /users/sign_up(.:format)             devise/registrations#new
  edit_user_registration GET    /users/edit(.:format)                devise/registrations#edit
                         PUT    /users(.:format)                     devise/registrations#update
                         DELETE /users(.:format)                     devise/registrations#destroy
  userResourceView_index GET    /userResourceView(.:format)          userResourceView#index
                         POST   /userResourceView(.:format)          userResourceView#create
    new_userResourceView GET    /userResourceView/new(.:format)      userResourceView#new
   edit_userResourceView GET    /userResourceView/:id/edit(.:format) userResourceView#edit
        userResourceView GET    /userResourceView/:id(.:format)      userResourceView#show
                         PUT    /userResourceView/:id(.:format)      userResourceView#update
                         DELETE /userResourceView/:id(.:format)      userResourceView#destroy
           learningPaths GET    /learningPaths(.:format)             learningPaths#index
                         POST   /learningPaths(.:format)             learningPaths#create
        new_learningPath GET    /learningPaths/new(.:format)         learningPaths#new
       edit_learningPath GET    /learningPaths/:id/edit(.:format)    learningPaths#edit
            learningPath GET    /learningPaths/:id(.:format)         learningPaths#show
                         PUT    /learningPaths/:id(.:format)         learningPaths#update
                         DELETE /learningPaths/:id(.:format)         learningPaths#destroy
              home_index GET    /home/index(.:format)                home#index
                   login GET    /login(.:format)                     devise/sessions#new
        new_user_session GET    /sign_in(.:format)                   devise/sessions#new
                         POST   /sign_in(.:format)                   devise/sessions#create
    destroy_user_session DELETE /sign_out(.:format)                  devise/sessions#destroy
                         POST   /password(.:format)                  devise/passwords#create
                         GET    /password/new(.:format)              devise/passwords#new
                         GET    /password/edit(.:format)             devise/passwords#edit
                         PUT    /password(.:format)                  devise/passwords#update
                         GET    /cancel(.:format)                    devise/registrations#cancel
                         POST   /                                    devise/registrations#create
                         GET    /register(.:format)                  devise/registrations#new
                         GET    /edit(.:format)                      devise/registrations#edit
                         PUT    /                                    devise/registrations#update
                         DELETE /                                    devise/registrations#destroy
            user_profile        /user_profile(.:format)              users#index
                     tag GET    /tags/:tag(.:format)                 resources#index
                                /auth/:provider/callback(.:format)   authentications#create
                                /auth/:provider/failure(.:format)    authentications#failure
                         POST   /resources(.:format)                 resources#create
                 contact GET    /contact(.:format)                   contact#new
                 contact POST   /contact(.:format)                   contact#create
                  forums        /forums(.:format)                    forums#index
                    home        /                                    home#index

Routes for Engage::Engine:
                       root        /                                                 engage/topics#index
             topic_comments POST   /topics/:topic_id/comments(.:format)              engage/comments#create
          new_topic_comment GET    /topics/:topic_id/comments/new(.:format)          engage/comments#new
              topic_comment DELETE /topics/:topic_id/comments/:id(.:format)          engage/comments#destroy
                 topic_vote GET    /topics/:topic_id/vote(.:format)                  engage/votes#create
                            POST   /topics/:topic_id/vote(.:format)                  engage/votes#create
                            DELETE /topics/:topic_id/vote(.:format)                  engage/votes#destroy
unsubscribe_topic_following GET    /topics/:topic_id/following/unsubscribe(.:format) engage/followings#destroy
            topic_following GET    /topics/:topic_id/following(.:format)             engage/followings#create
                            POST   /topics/:topic_id/following(.:format)             engage/followings#create
                            DELETE /topics/:topic_id/following(.:format)             engage/followings#destroy
                     topics GET    /topics(.:format)                                 engage/topics#index
                            POST   /topics(.:format)                                 engage/topics#create
                  new_topic GET    /topics/new(.:format)                             engage/topics#new
                 edit_topic GET    /topics/:id/edit(.:format)                        engage/topics#edit
                      topic GET    /topics/:id(.:format)                             engage/topics#show
                            PUT    /topics/:id(.:format)                             engage/topics#update
                            DELETE /topics/:id(.:format)                             engage/topics#destroy
        set_intended_action POST   /set_intended_action(.:format)                    engage/application#set_intended_action
          user_user_profile PUT    /users/:user_id/user_profile(.:format)            engage/user_profiles#update
                      users GET    /users(.:format)                                  engage/users#index

また、エラーにはapp / views / shared/_header.html.erbが記載されています。そのファイルは次のとおりです。

<div id="header">

    <div id="logoText">

        <%= link_to "Knowledge Thief", url_for(:action=>"index", :controller=>"home") %> 
    </div>

    <div class="signin">

    <a href="#">

        <div class="notifications unread">

            3

        </div>

    </a>

       <% unless current_user.nil? %>
           <%= link_to "#{current_user.email}", url_for(:action=>"user") %>
       <% else %>
           <%= link_to "Sign In", url_for(current_user) %>
       <% end %>
        <%= link_to image_tag("downArrow.png", :style => "height:5px;margin-left:3px;vertical-align:middle;"), url_for(current_user) %> 
    </div>


 </div>

これまでに行った手順(更新予定):

  1. 必ずバンドルインストールしてください
  2. rake db:resetを実行しました
  3. rake db:migrateを実行しました
  4. 2日前から現在までの間に何が起こったのかをチームに尋ねました。gitログなどを調べていきます。

これで、/engageがengageにルーティングされていることがわかりますが、この/ homeはどこから来ているのですか?/engageはengage/topics#indexに行くべきではありませんか?

4

1 に答える 1

2

メインアプリケーションにホームコントローラーのセットアップがありますか?その理由は、ホームコントローラーのアクションにインデックスを付けるためのリンクを使用している_header.html.erbファイルにあります。

メインアプリケーションのレイアウト/テンプレートを使用してエンジンのビューをレンダリングしていると思います。また、_header.html.erbは、エンジンのビューをレンダリングするテンプレートの一部でもあります。

レール内のマウント可能なエンジンは、メインアプリケーションのコントローラー/アクションのルートにアクセスする場合は、 main_appを呼び出す必要があるように機能します。したがって、 link_to行を次のように変更できます。

<%= link_to "Knowledge Thief", main_app.home_path %> 
于 2013-02-04T20:18:11.307 に答える