我正在尝试使用 heroku 控制台将记录从 false 更改为 true。
我尝试过的一切都给出了同样的错误。
我试过这样:
entry.boolean = true
entry.save
它总是给出这个错误:
TypeError: can't convert Fixnum into String
接下来我应该尝试什么?
这是来自控制台的完整错误:
Loading production environment (Rails 3.2.9)
irb(main):001:0> entry = RegisterEntry.first
RegisterEntry Load (53.6ms) SELECT "register_entries".* FROM "register_entries" LIMIT 1
=> #<RegisterEntry id: 5, checkout: "2012-10-03", checkin: "2012-12-23", notes: "", publisher_id: 42, territory_id: 79, created_at: "2012-12-23 20:52:06", updated_at: "2012-12-23 20:54:27", written: false>
irb(main):002:0> entry.written = true
=> true
irb(main):003:0> entry.save
(2.1ms) BEGIN
(2.5ms) UPDATE "register_entries" SET "written" = 't', "updated_at" = '2012-12-24 12:32:45.224914' WHERE "register_entries"."id" = 5
Territory Load (17.2ms) SELECT "territories".* FROM "territories" WHERE "territories"."id" = 79 LIMIT 1
Publisher Load (18.7ms) SELECT "publishers".* FROM "publishers" WHERE "publishers"."id" = 42 LIMIT 1
(3.5ms) ROLLBACK
TypeError: can't convert Fixnum into String
from /app/app/models/register_entry.rb:30:in `delete'
from /app/app/models/register_entry.rb:30:in `block in <class:RegisterEntry>'
from /app/vendor/bundle/ruby/1.9.1/gems/activesupport-3.2.9/lib/active_support/callbacks.rb:405:in `_run__731746304271343388__update__2234592017401079067__callbacks'
from /app/vendor/bundle/ruby/1.9.1/gems/activesupport-3.2.9/lib/active_support/callbacks.rb:405:in `__run_callback'
from /app/vendor/bundle/ruby/1.9.1/gems/activesupport-3.2.9/lib/active_support/callbacks.rb:385:in `_run_update_callbacks'
from /app/vendor/bundle/ruby/1.9.1/gems/activesupport-3.2.9/lib/active_support/callbacks.rb:81:in `run_callbacks'
from /app/vendor/bundle/ruby/1.9.1/gems/activerecord-3.2.9/lib/active_record/callbacks.rb:272:in `update'
from /app/vendor/bundle/ruby/1.9.1/gems/activerecord-3.2.9/lib/active_record/persistence.rb:348:in `create_or_update'
from /app/vendor/bundle/ruby/1.9.1/gems/activerecord-3.2.9/lib/active_record/callbacks.rb:264:in `block in create_or_update'
from /app/vendor/bundle/ruby/1.9.1/gems/activesupport-3.2.9/lib/active_support/callbacks.rb:425:in `_run__731746304271343388__save__2234592017401079067__callbacks'
from /app/vendor/bundle/ruby/1.9.1/gems/activesupport-3.2.9/lib/active_support/callbacks.rb:405:in `__run_callback'
from /app/vendor/bundle/ruby/1.9.1/gems/activesupport-3.2.9/lib/active_support/callbacks.rb:385:in `_run_save_callbacks'
from /app/vendor/bundle/ruby/1.9.1/gems/activesupport-3.2.9/lib/active_support/callbacks.rb:81:in `run_callbacks'
from /app/vendor/bundle/ruby/1.9.1/gems/activerecord-3.2.9/lib/active_record/callbacks.rb:264:in `create_or_update'
from /app/vendor/bundle/ruby/1.9.1/gems/activerecord-3.2.9/lib/active_record/persistence.rb:84:in `save'
from /app/vendor/bundle/ruby/1.9.1/gems/activerecord-3.2.9/lib/active_record/validations.rb:50:in `save'
from /app/vendor/bundle/ruby/1.9.1/gems/activerecord-3.2.9/lib/active_record/attribute_methods/dirty.rb:22:in `save'
from /app/vendor/bundle/ruby/1.9.1/gems/activerecord-3.2.9/lib/active_record/transactions.rb:259:in `block (2 levels) in save'
from /app/vendor/bundle/ruby/1.9.1/gems/activerecord-3.2.9/lib/active_record/transactions.rb:313:in `block in with_transaction_returning_status'
from /app/vendor/bundle/ruby/1.9.1/gems/activerecord-3.2.9/lib/active_record/connection_adapters/abstract/database_statements.rb:192:in `transaction'
from /app/vendor/bundle/ruby/1.9.1/gems/activerecord-3.2.9/lib/active_record/transactions.rb:208:in `transaction'
from /app/vendor/bundle/ruby/1.9.1/gems/activerecord-3.2.9/lib/active_record/transactions.rb:311:in `with_transaction_returning_status'
from /app/vendor/bundle/ruby/1.9.1/gems/activerecord-3.2.9/lib/active_record/transactions.rb:259:in `block in save'
from /app/vendor/bundle/ruby/1.9.1/gems/activerecord-3.2.9/lib/active_record/transactions.rb:270:in `rollback_active_record_state!'
from /app/vendor/bundle/ruby/1.9.1/gems/activerecord-3.2.9/lib/active_record/transactions.rb:258:in `save'
from (irb):3
from /app/vendor/bundle/ruby/1.9.1/gems/railties-3.2.9/lib/rails/commands/console.rb:47:in `start'
from /app/vendor/bundle/ruby/1.9.1/gems/railties-3.2.9/lib/rails/commands/console.rb:8:in `start'
from /app/vendor/bundle/ruby/1.9.1/gems/railties-3.2.9/lib/rails/commands.rb:41:in `<top (required)>'
from script/rails:6:in `require'