Не найдено ни одного маршрута "/ index".Простая проблема? - PullRequest
5 голосов
/ 28 августа 2011

Новое во всех мирах программирования и новое в RoR. Я делал урок и столкнулся с некоторыми проблемами прошлой ночью. Мой друг помог с некоторыми из них. Я спросил несколько здесь. И все же этот сбивает с толку меня. Я не могу найти проблему этого.

Страница загружается, она показывает, что нужно показывать. Но когда я нажимаю на ссылку там, это приводит к следующему:

    Routing Error

No route matches "/index"

Итак, я сделал rake routes и получил это

Dennis-Buizerts-MacBook-Pro:gpoff dennisbuizert$ rake routes
site_index GET /site/index(.:format) {:controller=>"site", :action=>"index"}
site_about GET /site/about(.:format) {:controller=>"site", :action=>"about"}
 site_help GET /site/help(.:format)  {:controller=>"site", :action=>"help"}
      root     /(.:format)           {:controller=>"Site", :action=>"index"}

Это в моих маршрутах.рб

root :to => "Site#index"
get "site/index"       
get "site/about"
get "site/help"

Я пытался добавить map.connects и match, но это не помогло. А мой журнал development.log говорит следующее:

Started GET "/" for 127.0.0.1 at 2011-08-28 10:05:51 +0200
DEPRECATION WARNING: Disabling sessions for a single controller has been deprecated. Sessions are now lazy loaded. So if you don't access them, consider them off. You can still modify the session cookie options with request.session_options. (called from <class:ApplicationController> at /Users/dennisbuizert/Sites/gpoff/app/controllers/application_controller.rb:3)
  Processing by SiteController#index as HTML
Rendered site/index.html.erb within layouts/application (1.6ms)
Completed 200 OK in 5ms (Views: 4.3ms | ActiveRecord: 0.0ms)


Started GET "/index" for 127.0.0.1 at 2011-08-28 10:05:52 +0200

ActionController::RoutingError (No route matches "/index"):


Rendered /Users/dennisbuizert/.rvm/gems/ruby-1.9.2-p290/gems/actionpack-3.0.10/lib/action_dispatch/middleware/templates/rescues/routing_error.erb within rescues/layout (0.8ms)

1 Ответ

4 голосов
/ 28 августа 2011

Попробуйте

get 'index' => "site#index"

вместо

get "site/index"  
Добро пожаловать на сайт PullRequest, где вы можете задавать вопросы и получать ответы от других членов сообщества.
...