Skip to content

NoMethodError: undefined method `incr' for nil:NilClass #13

@scalp42

Description

@scalp42

Hi @german,

Thanks a lot for the gem.

I tried to replicate the example in the README and using the current master@2aa6160. Unfortunately, when trying to create or call .save on a new class, I'm running into the following issue:

class Article < RedisOrm::Base
  property :title, String
  has_many :comments
end

class Comment < RedisOrm::Base
  property :body, String
  property :moderated, RedisOrm::Boolean, :default => false
  index :moderated
  belongs_to :article
end
[12] pry(main)> article = Article.create :title => "DHH drops OpenID on 37signals"
NoMethodError: undefined method `incr' for nil:NilClass

Do you happen to have an idea by any chance? It looks $redis is nil:

    def get_next_id
      if @@use_uuid_as_id[model_name]
        @@uuid.generate(:compact)
      else
        $redis.incr("#{model_name}:id")
      end
    end

Thanks in advance!

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions