小编use*_*341的帖子

Rails 4控制器中的运行时错误:自动加载常量时检测到循环依赖性

如果我遗漏了任何东西,请告诉我.我无法弄清楚为什么我的views/references /文件夹无法访问.既不可用new.html.erb也不index.html.erb可用.当我转到localhost:3000/references我的错误是:

RuntimeError in ReferencesController#index
Circular dependency detected while autoloading constant ReferencesController
Run Code Online (Sandbox Code Playgroud)

我相信这是设置,它不应该是一个Rails问题,因为我的其他控制器工作正常.

我的路线文件中有resources :references我的rake路线产生:

references GET    /references(.:format)          references#index
           POST   /references(.:format)          references#create
new_reference GET    /references/new(.:format)      references#new
edit_reference GET    /references/:id/edit(.:format) references#edit
reference GET    /references/:id(.:format)      references#show
           PATCH  /references/:id(.:format)      references#update
           PUT    /references/:id(.:format)      references#update
           DELETE /references/:id(.:format)      references#destroy
Run Code Online (Sandbox Code Playgroud)

所以我试着通过这个到达我的索引页面,这应该是正确的路径.

<%= link_to 'References', references_path, class: 'navbar-brand' %>
Run Code Online (Sandbox Code Playgroud)

我的模特:

class Reference < ActiveRecord::Base
  belongs_to :user
end
Run Code Online (Sandbox Code Playgroud)

我的控制器:

class ReferencesControllers < ApplicationController
  def index
    @references = Reference.all
  end
Run Code Online (Sandbox Code Playgroud)

谷歌搜索后,似乎每个类似的问题都是从Rails 3升级到Rails …

ruby ruby-on-rails circular-dependency controllers ruby-on-rails-4

9
推荐指数
1
解决办法
2万
查看次数

PG :: ConnectionBad FATAL:角色"myapp"不存在

我可以使用postgres.app在Mac上使用postgres.app在应用内部输入rails而没有任何问题,但是,当我转到localhost:3000时,它给了我这个错误:

PG::ConnectionBad
FATAL: role "myapp" does not exist
Run Code Online (Sandbox Code Playgroud)

我一开始认为问题是database.yml文件,但是heroku docs甚至说它的方式是这样的:https://devcenter.heroku.com/articles/getting-started-with-rails4

development:
adapter: postgresql
encoding: unicode
database: myapp_development
pool: 5
username: myapp
password:
Run Code Online (Sandbox Code Playgroud)

这是我的完整日志.我见过类似的问题,但他们只是模糊地与此有关.

片段:

Started GET "/" for 127.0.0.1 at 2014-03-25 16:48:31 -0600

PG::ConnectionBad (FATAL:  role "myapp" does not exist
):
  activerecord (4.0.2) lib/active_record/connection_adapters/postgresql_adapter.rb:831:in `initialize'
  activerecord (4.0.2) lib/active_record/connection_adapters/postgresql_adapter.rb:831:in `new'
  activerecord (4.0.2) lib/active_record/connection_adapters/postgresql_adapter.rb:831:in `connect'
  activerecord (4.0.2) lib/active_record/connection_adapters/postgresql_adapter.rb:548:in `initialize'
  activerecord (4.0.2) lib/active_record/connection_adapters/postgresql_adapter.rb:41:in `new'
  activerecord (4.0.2) lib/active_record/connection_adapters/postgresql_adapter.rb:41:in `postgresql_connection'
  activerecord (4.0.2) lib/active_record/connection_adapters/abstract/connection_pool.rb:440:in `new_connection'
  activerecord (4.0.2) lib/active_record/connection_adapters/abstract/connection_pool.rb:450:in `checkout_new_connection'
  activerecord (4.0.2) lib/active_record/connection_adapters/abstract/connection_pool.rb:421:in `acquire_connection' …
Run Code Online (Sandbox Code Playgroud)

postgresql ruby-on-rails heroku

6
推荐指数
2
解决办法
9981
查看次数