Routing-Fehler im rails-app "initialisierten Konstanten HomeController'

Im neuen zu verwenden foundation und ich erstellt haben, einfach Posten-app mit Gerüst
und ich habe getan, folgende Schritte:

rails new blog

fügte dann Folgendes zu Gemfile

gem 'foundation-rails'
group :development do
  gem 'rails_layout'
end

dann

$ bundle install
$ rails generate layout:install foundation5 --force
$ rails g scaffold Post title desc:text
$ rake db:migrate

Nun die app läuft wunderbar @ local-host-port 3000/posts
Routing-Fehler im rails-app
Aber wenn ich auf 'Home' - button in der nav-bar, die es erzeugt Fehler:
Routing-Fehler im rails-app

Anwendung.html-Code.erb-Datei:

<!DOCTYPE html>
<html>
  <head>
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title><%= content_for?(:title) ? yield(:title) : "Found Rails" %></title>
    <meta name="description" content="<%= content_for?(:description) ? yield(:description) : "Found Rails" %>">
    <%= stylesheet_link_tag 'application', media: 'all', 'data-turbolinks-track' => true %>
    <%# Modernizr is required for Zurb Foundation %>
    <%= javascript_include_tag 'vendor/modernizr' %>
    <%= javascript_include_tag 'application', 'data-turbolinks-track' => true %>
    <%= csrf_meta_tags %>
  </head>
  <body>
    <header>
      <%= render 'layouts/navigation' %>
    </header>
    <main role="main">
       <%= render 'layouts/messages' %>
       <%= yield %>
    </main>
  </body>
</html>

_navigation.html-Code.erb-Datei :

<%# navigation styled for Zurb Foundation 5 %>
<nav class="top-bar" data-topbar>
  <ul class="title-area">
    <li class="name"><%= link_to 'Home', root_path %></li>
    <li class="toggle-topbar menu-icon"><a href="#">Menu</a></li>
  </ul>
  <div class="top-bar-section">
    <ul>
      <%= render 'layouts/navigation_links' %>
    </ul>
  </div>
</nav>

Meiner Wege.rb-Datei:

Rails.application.routes.draw do
  resources :posts
  root :to => "home#index"

  # The priority is based upon order of creation: first created -> highest priority.
  # See how all your routes lay out with "rake routes".

  # You can have the root of your site routed with "root"
  # root 'welcome#index'

  # Example of regular route:
  #   get 'products/:id' => 'catalog#view'

  # Example of named route that can be invoked with purchase_url(id: product.id)
  #   get 'products/:id/purchase' => 'catalog#purchase', as: :purchase

  # Example resource route (maps HTTP verbs to controller actions automatically):
  #   resources :products

  # Example resource route with options:
  #   resources :products do
  #     member do
  #       get 'short'
  #       post 'toggle'
  #     end
  #
  #     collection do
  #       get 'sold'
  #     end
  #   end

  # Example resource route with sub-resources:
  #   resources :products do
  #     resources :comments, :sales
  #     resource :seller
  #   end

  # Example resource route with more complex sub-resources:
  #   resources :products do
  #     resources :comments
  #     resources :sales do
  #       get 'recent', on: :collection
  #     end
  #   end

  # Example resource route with concerns:
  #   concern :toggleable do
  #     post 'toggle'
  #   end
  #   resources :posts, concerns: :toggleable
  #   resources :photos, concerns: :toggleable

  # Example resource route within a namespace:
  #   namespace :admin do
  #     # Directs /admin/products/* to Admin::ProductsController
  #     # (app/controllers/admin/products_controller.rb)
  #     resources :products
  #   end
end

Was ist es, was im fehlt?.

Haben Sie einen HomeController?
nicht das, was definiert werden sollte ?
Du bist Bewurzelung Ihr '/' url auf einen HomeController. Run "rails g controller home index' und versuchen Sie es dann erneut.

InformationsquelleAutor PallavSharma | 2014-05-05

Schreibe einen Kommentar