Reputation: 1191
I'm relatively new to RoR and I'm having problem with NoMethodError.
So I'm doing this in rails console, I get this error message when I tried calling .create method. (Same thing with .save and .reload). I thought that those methods should be inherited from somewhere?
irb(main):001:0> User.create
NoMethodError: undefined method `create'
from (irb):1
from C:/RailsInstaller/Ruby1.9.2
/lib/rails/commands/console.rb:45:in `st
from C:/RailsInstaller/Ruby1.9.2
/lib/rails/commands/console.rb:8:in `sta
from C:/RailsInstaller/Ruby1.9.2
/lib/rails/commands.rb:40:in `<top (requ
from script/rails:6:in `require'
from script/rails:6:in `<main>'
Does anyone know the source of the problem? Thanks.
EDIT
User class is defined as:
class User < ActiveRecord::Base
attr_accessible :name, :email
end
GEMFILE content is:
gem 'rails', '3.1.1'
gem 'sqlite3'
gem 'jquery-rails'
group :assets do
gem 'sass-rails', '~> 3.1.4'
gem 'coffee-rails', '~> 3.1.1'
gem 'uglifier', '>= 1.0.3'
end
group :test do
gem 'turn', :require => false
end
Upvotes: 0
Views: 902
Reputation: 2859
Do you have a migration file to create users table under your /db/migrate
? If so, did you run rake db:migrate
? Make sure to start your console as rails console
Upvotes: 0