我无法保存 Rails 模型,它显示“ActiveRecord::RecordNotSaved”。提前谢谢。
m = Mentor.last
m.save
=> false
m.save!
ActiveRecord::RecordNotSaved
m.valid?
=> true
m.errors.any?
=> false
错误跟踪是:
from /home/charizard/.rvm/gems/ruby-1.9.3-p429/gems/activerecord-3.2.2/lib/active_record/persistence.rb:104:in `save!'
from /home/charizard/.rvm/gems/ruby-1.9.3-p429/gems/activerecord-3.2.2/lib/active_record/validations.rb:56:in `save!'
from /home/charizard/.rvm/gems/ruby-1.9.3-p429/gems/activerecord-3.2.2/lib/active_record/attribute_methods/dirty.rb:33:in `save!'
from /home/charizard/.rvm/gems/ruby-1.9.3-p429/gems/activerecord-3.2.2/lib/active_record/transactions.rb:246:in `block in save!'
from /home/charizard/.rvm/gems/ruby-1.9.3-p429/gems/activerecord-3.2.2/lib/active_record/transactions.rb:295:in `block in with_transaction_returning_status'
from /home/charizard/.rvm/gems/ruby-1.9.3-p429/gems/activerecord-3.2.2/lib/active_record/connection_adapters/abstract/database_statements.rb:192:in `transaction'
from /home/charizard/.rvm/gems/ruby-1.9.3-p429/gems/activerecord-3.2.2/lib/active_record/transactions.rb:208:in `transaction'
from /home/charizard/.rvm/gems/ruby-1.9.3-p429/gems/activerecord-3.2.2/lib/active_record/transactions.rb:293:in `with_transaction_returning_status'
from /home/charizard/.rvm/gems/ruby-1.9.3-p429/gems/activerecord-3.2.2/lib/active_record/transactions.rb:246:in `save!'
from (irb):120
from /home/charizard/.rvm/gems/ruby-1.9.3-p429/gems/railties-3.2.2/lib/rails/commands/console.rb:47:in `start'
from /home/charizard/.rvm/gems/ruby-1.9.3-p429/gems/railties-3.2.2/lib/rails/commands/console.rb:8:in `start'
from /home/charizard/.rvm/gems/ruby-1.9.3-p429/gems/railties-3.2.2/lib/rails/commands.rb:41:in `<top (required)>'
from script/rails:6:in `require'
from script/rails:6:in `<main>'