已使用的路线名称无效:' root' (M. Hartl教程)

时间:2015-09-15 19:04:13

标签: ruby-on-rails ruby-on-rails-4 heroku console

我遇到了一个我几天都无法解决的问题。我一直在寻找StackOverflow同样的问题,肯定还有其他类似的问题,但是对Rails来说太新了我发现的大多数东西对我的水平来说有点太高级了,我不确定它们是否适用于我。

所以,问题是这个。

我遵循一个教程(Hartl' s),在某些时候我必须在Heroku上部署,这没关系,但是当我运行时

heroku run console --sandbox

我收到错误

Invalid route name, already in use: 'root' 

这是来自控制台的消息:

Invalid route name, already in use: 'root'  (ArgumentError)
You may have defined two routes with the same name using the `:as` option,
or you may be overriding a route already defined by a resource with the
same naming.

部署到Heroku时我也收到一些警告,我不确定是否与此问题有关:

remote: ###### WARNING:
remote:        Removing `Gemfile.lock` because it was generated on Windows.
remote:        Bundler will do a full resolve so native gems are handled
properly.
remote:        This may result in unexpected gem versions being used in your
app.
remote:        In rare occasions Bundler may not be able to resolve your
dependencies at all.

remote: ###### WARNING:
remote:        You have not declared a Ruby version in your Gemfile.
remote:        To set your Ruby version add this line to your Gemfile:
remote:        ruby '2.0.0'

remote: ###### WARNING:
remote:        Removing `Gemfile.lock` because it was generated on Windows.
remote:        Bundler will do a full resolve so native gems are handled 
properly.
remote:        This may result in unexpected gem versions being used in your
app.
remote:        In rare occasions Bundler may not be able to resolve your 
dependencies at all.

remote: ###### WARNING:
remote:        No Procfile detected, using the default web server (webrick)

当我尝试在生产环境中启动服务器时,我也遇到了同样的错误:

bundle exec rake db:migrate RAILS_ENV=production

然后

rails server --environment production

测试和开发环境都很好,但不是生产环境。凭借我仍然缺乏的知识,我猜测它与此有关,但同样,我觉得我已经进入了圈子。

这是我的routes.rb文件(它非常简单,所以我没有看到问题):

Rails.application.routes.draw do

  root                 'static_pages#home'
  get 'help'       =>  'static_pages#help'
  get 'about'      =>  'static_pages#about'
  get 'contact'    =>  'static_pages#contact'
  get 'users/new'  =>  'users#new'
  resources :users

end

这一切都无法阻止我继续学习本教程,因为其他一切正常,但这只会让我感到烦恼,我只需要弄清楚问题是什么!可能是一些错误,还有别的?我真的不知道了。这可能是非常简单的事情,但我已经厌倦了寻找问题。

无论如何,如果您需要我拥有的任何其他文件的来源,我会发布它。仅供参考,我在演习前的第6章结束时。我必须指出,这是我在尝试使用“运行控制台”时发现的问题。命令。这个问题可能以前出现过,但我从未遇到过这个问题。

编辑:如果你能指出我某个方向,某个地方我没有看过或考虑过,就像有些想法那样......它会非常感激!

编辑:我忘了包括我在cloud9 IDE中工作,如果这很重要的话。

' rake路线的输出'命令:

 root      GET  /                    'static_pages#home'
 help      GET  /help(.:format)      'static_pages#help'
 contact   GET  /contact(.:format)   'static_pages#contact'
 about     GET  /about(.:format)     'static_pages#about'
 users_new GET  /users/new(.:format) 'users#new'

0 个答案:

没有答案