【发布时间】:2014-11-19 20:02:07
【问题描述】:
我有一个模型Account 位于/app/models/account.rb 下:
class Account < ActiveRecord::Base
end
当我现在请求控制器时,我得到 undefined method all for Account:Module:
class AccountsController < ApplicationController
def index
@accounts = Account.all
end
end
我尝试将模型重命名为 Accounte,这确实有效。但是,我看到很多使用 Account 模型的 Rails 教程,而且真的很难找到其他名称。
如何找到并禁用帐户模块以清除此命名冲突?
我可以通过rails console 访问坏 Account。
【问题讨论】:
-
我假设你自己的代码库中没有一个名为
Account的模块,你的 Gemfile 中有什么宝石 -
您是否有任何可以添加
Account模块的宝石? -
另外,try this,它可能会帮助您找出另一个
Account模块的定义位置。 -
@UriAgassi 我有
rails~4.1.8、mysql2~0.3.17和spring。 -
啊,我刚刚发现我最初运行的是
rails new account,所以config/application.rb定义了module Account。
标签: ruby-on-rails ruby