Sha*_*ane 1 ruby activerecord ruby-on-rails
2.0.0-p247 :006 > load './app/models/user.rb'
NameError: uninitialized constant ActiveRecord
from /home/action/iAuth/app/models/user.rb:1:in `<top (required)>'
from (irb):6:in `load'
from (irb):6
from /home/action/.rvm/rubies/ruby-2.0.0-p247/bin/irb:13:in `<main>'
Run Code Online (Sandbox Code Playgroud)
以下是我的User Model.
class User < ActiveRecord::Base
end
Run Code Online (Sandbox Code Playgroud)
当我尝试加载我的时候user.rb in my irb,我得到了上面的错误.
开始你的irb会话
rails console
并不是:
irb
rails console会rails为您加载您的环境和模型,因此您可以执行以下操作:
User.all或User.new没有加载class,因为它已经预加载由rails console已
| 归档时间: |
|
| 查看次数: |
2332 次 |
| 最近记录: |