2016-11-22 6 views
0

初めてRuby on Railsを学習しています。私は昨日ラップトップからRubyを実行しているrvmとデスクトップをrbenvで実行していたのでいくつか問題があったので、それを修正しました。しかし今、私はラップトップで次のようなエラーが出ていますが、私のラップトップではすべて正常に動作します。UrlGenerationError 1つのコンピュータでは一致するルートはありません。

私はそれがうまくいくと信じています。コードを正しく理解すれば、カテゴリパスで@housingパラメータを渡して私の住宅カテゴリにリンクしています。

私の言ったように、これは私のデスクトップ上で動作します。

コードは次のとおりです。私のすくいルートから

出力が...私が使用しようとしていますルートを指定して、コマンド

category GET /categories/:id(.:format) categories#show 

index.html.erb

<div class="container"> 
    <div class="leftbar"> 
    <a href="#"><h1>rubyslist</h1></a> 
    <ul> 
     <a href="#"><%= link_to 'post a classifieds', new_listing_path %></a> 
     <li>my account</li> 
    </ul> 
     <p>search shiplist</p> 
     <%= form_tag search_listings_path, :method => 'get' do %> 
     <p> 
     <%= text_field_tag :search, params[:search] %> 
     <%= submit_tag "Search", :name => nil %> 
     </p> 
     <% end %> 
    </div> 
    <div class="center-column" > 
    <div class="center-one"> 
     <table> 
     <tr> 
      <th class="table-header"><%= link_to 'housing', category_path(@housing) %></th> 
     </tr> 
     <tr> 
      <td> 
      <% @housing.subcategories.each do |subcategory| %> 
      <ul class="left-list"> 
       <li><%= link_to subcategory.name, category_subcategory_path(@housing, subcategory) %></li> 
      </ul> 
      <% end %> 
      </td> 
     </tr> 
     </table> 
     <table> 
     <tr> 
      <th class="table-header"><%= link_to 'roommates', category_path(@roommates) %></th> 
     </tr> 
     <tr> 
      <td> 
      <% @roommates.subcategories.each do |subcategory| %> 
      <ul> 
       <li><%= link_to subcategory.name, category_subcategory_path(@roommates, subcategory) %></li> 
      </ul> 
      <% end %> 
      </td> 
     </tr> 
     </table> 
     <table> 
     <tr> 
      <th class="table-header"><%= link_to 'for sale', category_path(@forsale) %></th> 
     </tr> 
     <tr> 
      <td> 
      <% @forsale.subcategories.each do |subcategory| %> 
      <ul class="left-list"> 
       <li><%= link_to subcategory.name, category_subcategory_path(@forsale, subcategory) %></li> 
      </ul> 
      <% end %> 
      </td> 
     </tr> 
     </table> 
    </div> 
    </div> 
    <div class="rightbar"> 
    <!-- Links to the pages via routes match --> 
    <ul class="rightbar-top"> 
     <!-- /help --> 
     <li><%= link_to 'help and faq', help_path%></li> 
     <li><%= link_to 'avoid scams and fraud', scams_path%></li> 
     <li><%= link_to 'personal safety tips', safety_path%></li> 
     <li class="rightbar-top"><%= link_to 'terms of use', terms_path%></li> 
     <li><%= link_to 'privacy policy', privacy_path%></li> 
     <li><%= link_to 'about shiplist', about_path%></li> 
     <li><%= link_to 'contact us', contact_path%></li> 
    </ul> 
    </div> 
</div> 

routes.rbを

#Creates CRUD actions for categories 
    resources :categories do 
    #Append sub-categories to categories with CRUD 
    resources :subcategories 
    end 

    #Performs the search 
    resources :listings do 
    collection do 
     get 'search' 
    end 
    end 

    #Set homepage to index of categories 
    root 'categories#index' 

    #Matches the pages help action to a get request 
    #for the help page with page controller in help 
    #function of pages controller 
    match '/help', to: 'pages#help', via: :get 
    match '/scams', to: 'pages#scams', via: :get 
    match '/safety', to: 'pages#safety', via: :get 
    match '/about', to: 'pages#about', via: :get 
    match '/contact', to: 'pages#contact', via: :get 
    match '/privacy', to: 'pages#privacy', via: :get 
    match '/terms', to: 'pages#terms', via: :get 
    match '/subcategories/find_by_category', to: 'subcategories#find_by_category', via: :post 
end 

categories_controller.rb

問題を修正コマンド

rake db:seed 

を実行

答えて

関連する問題