【问题标题】:Rails App RAKE ROUTES does not return anythingRails App RAKE ROUTES 不返回任何内容
【发布时间】:2013-05-01 04:00:46
【问题描述】:

我构建了一个我在本地工作的 Rails 应用程序。在将它部署到我的网络主机时,我从 sqlite 更改为 mysql2 并更新了一些其他 gem。该应用程序已在 Web 主机上运行,​​但现在它不在本地运行。我已经尝试在本地使用 mysql2 和 sqlite。 如果我在开发(sqlite3)或生产(mysql2)中启动rails服务器,我可以运行rake db:droprake db:createrake 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

【问题讨论】:

  • 以前有用吗?如果是这样,你能找到你所做的改变吗?
  • 发布你的routes.rb文件怎么样?
  • 是的,请发布您的路线文件。其他人(感兴趣的人)可以通过这种方式更好地帮助您。

标签: ruby-on-rails ruby routes rake


【解决方案1】:

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

resources :posts do

应该关闭?

【讨论】:

    猜你喜欢
    • 2011-06-05
    • 2013-07-11
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2023-03-28
    • 2020-04-27
    • 2019-04-06
    • 2012-02-15
    相关资源
    最近更新 更多