我是在軌道上的紅寶石新。我創建了一個名爲member的類,其中包含一些變量,例如name,ext ext。當我在應用程序/模型打開member.rb,該類似乎空:我的Ruby類原來是空的,爲什麼不能創建屬性?
class Member < ActiveRecord::Base
end
我意識到,當我運行member.all
。它提供了錯誤:
NameError : undefined local variable or method 'member' for main:Object
感謝所有幫助
[爲什麼rails會生成空模型?](http://stackoverflow.com/questions/19323870 /爲什麼 - 軌道 - 是 - 生成空模型) – jcm
您是否使用'rails generate ...'生成模型?您可能是指您的列名,它們位於您的遷移文件中。什麼版本的Rails? 'member.all'也是錯的,它會是'Member.all'。 – Beartech