Undefined to_i method using Devise from console

I am trying to devise for the first time. I created a basic input / output system and tried to create some objects from the console and noticed something strange:

rails c --sandbox
Loading development environment in sandbox (Rails 4.1.5)
Any modifications you make will be rolled back on exit

Frame number: 0/20
[1] »  u = User.last
  User Load (0.7ms)  SELECT  "users".* FROM "users"   ORDER BY "users"."id" DESC LIMIT 1
(pry) output error: #<NoMethodError: undefined method `to_i' for #<Object:0x007fd988871540>>
[2] »  u
(pry) output error: #<NoMethodError: undefined method `to_i' for #<Object:0x007fd988871540>>
[3] »  u.id
=> 5

Why does the console throw an error on my object? The same thing happens with User.last, etc.

Here is my diagram:

create_table "users", force: true do |t|
    t.string   "email",                  default: "", null: false
    t.string   "encrypted_password",     default: "", null: false
    t.string   "reset_password_token"
    t.datetime "reset_password_sent_at"
    t.datetime "remember_created_at"
    t.integer  "sign_in_count",          default: 0,  null: false
    t.datetime "current_sign_in_at"
    t.datetime "last_sign_in_at"
    t.inet     "current_sign_in_ip"
    t.inet     "last_sign_in_ip"
    t.datetime "created_at"
    t.datetime "updated_at"
  end
+4
source share
2 answers

Do you have gem jazzy_hands installed? That was the reason in our case.

+2
source

Easy helper is to add it to .pryrc

module AwesomePrint
  class Formatter

    private

    def awesome_self(object, type)
      if @options[:raw] && object.instance_variables.any?
        awesome_object(object)
      elsif object.respond_to?(:to_hash)
        awesome_hash(object.to_hash)
      else
        colorize(object.inspect.to_s, type)
      end
    end
  end
end
+4
source

All Articles