Rails cells 的陷阱

edokeh · May 30, 2012 · Last by edokeh replied at May 30, 2012 · 2956 hits

今天堆码时候发现一个奇怪的问题 我定义了一个叫做 Sidebar 的类,然后在 controller 中试图初始化类的实例,结果总是报错 undefined method new for Sidebar:Module

奇怪,难道是 Sidebar 已经在哪里被定义成了 Module 了? 结果找了半天,发现原来是 cells 的问题,因为我曾经定义了一个 cells rails g cell Sidebar show

然后 cells 这个 gem 貌似隐式地创建了 Sidebar 这个 module,所以冲突了 现在只能暂时通过改名来避免了,不知道大家有没有更好的办法?

http://stackoverflow.com/questions/9807827/preventing-warning-toplevel-constant-b-referenced-by-ab-with-namespaced-cla 发现有人跟我有类似的情况,看来这个 module 可能不是 cells 创建的,而是 rails 自身的机制 唉,麻烦啊

You need to Sign in before reply, if you don't have an account, please Sign up first.