开发者

rails console error

开发者 https://www.devze.com 2023-03-15 16:08 出处:网络
I\'m trying to user rails console but every time I type a command I get NameError: undefined local variable or method `user\' for main:Object

I'm trying to user rails console but every time I type a command I get

NameError: undefined local variable or method `user' for main:Object
    from (irb):3
    from /Users/Home/.rvm/gems/ruby-1.9.2-p180@rails3/gems/railties-3.0.9/lib/rails/commands/console.rb:44:in `start'
    from /Users/Home/.rvm/gems/ruby-1.9.2-p180@rails3/gems/railties-3.0.9/lib/rails/commands/console.rb:8:in `start'
    from /Users/Home/.rvm/gems/ruby-1.9.2-p180@rails3/gems/railties-3.0.9/lib/rails/commands.rb:23:in `<top (required)>'
    from script/rai开发者_开发百科ls:6:in `require'
    from script/rails:6:in `<main>'

I couldn't view any of my models or even perform basic things

Could anyone please give any suggestion?

Many Thanks Ans


You can also use

user = User.new(//constructor parameters)

or

user = User.create(//constructor parameters)

or

user = User.new() //blank user object

the second method will create and save your record.

0

精彩评论

暂无评论...
验证码 换一张
取 消