0

我构建了一个我在本地工作的 Rails 应用程序。在将它部署到我的网络主机时,我从 sqlite 更改为 mysql2 并更新了一些其他 gem。该应用程序已在 Web 主机上运行,​​但现在它不在本地运行。我已经尝试在本地使用 mysql2 和 sqlite。如果我在开发(sqlite3)或生产(mysql2)中启动 rails 服务器,我可以运行rake db:drop rake db:create rake db:migrate. 它们运行良好,我可以在数据库浏览器或工作台中确认这一点。

当我运行 rake 路线时,它找不到任何路线。

 RAKE ROUTES --Trace
** Invoke routes (first_time)
** Invoke environment (first_time)
** Execute environment
** Execute routes

以上是返回的所有内容,当我浏览到我的应用程序的主页时,我收到错误:

Internal Server Error: undefined method `info' for nil:NilClass

什么会导致 Rake Routes 忽略或找不到 routes.rb 中的所有路由?

下面是我的 routes.rb 文件。

MyApp::Application.routes.draw do

get "users/new"

get "answers/new"

get "quizzes/new"

get "flashcards/new"

resources :posts do
resources :comments

 resources :users
 resources :flashcards  #, only: [:new, :create, :destroy]
 resources :sessions, only: [:new, :create, :destroy]
 resources :posts, only: [:new, :create, :destroy]

  #get "users/enter"

root :to => 'pages#home'
match '/', :to => 'pages#home'

match '/contact', :to => 'pages#contact'
match '/about', :to => 'pages#about'  

match '/ghostx', :to => 'users#ghostx'
match '/users/1', :to => 'users#ghostx'

match '/enter', :to => 'sessions#new'
match '/exit', :to => 'sessions#destroy'

match'/flashcards', to:  'flashcards#index'
match '/check', :to => 'flashcards#check'
match '/flash', :to => 'flashcards#pullcard'
match '/search', :to => 'flashcards#search'
end
4

1 回答 1

1

您正在打开两个块,但只有一个end语句。这个区块在哪里

resources :posts do

应该关闭?

于 2013-05-02T04:38:33.780 回答