1

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'
4

1 に答える 1

0

試すentry.update_attribute(:boolean, true)

于 2012-12-24T12:40:28.973 に答える