This has been cross-shown in ruby-talk .
ActiveRecord is a class that speaks to databases, this pearl awaits launch in the context of connecting the database to the loadable ActiveRecord. If you are in Rails, this means loading the Rails environment. Or, if only ActiveRecord, something like this would work:
require 'active_record' require 'circle' ActiveRecord::Base.establish_connection adapter: 'sqlite3', database: ':memory:' ActiveRecord::Schema.define do self.verbose = false create_table :users do |t| t.string :name t.integer :friends_count, :default => 0, :null => false end create_table :friendships, :force => true do |t| t.references :user, :friend t.datetime :requested_at, :accepted_at, :denied_at, :blocked_at t.string :status t.timestamps end create_table :blocked_users, :force => true do |t| t.references :user, :blocked_user t.timestamps end change_table :friendships do |t| t.index :user_id t.index :friend_id t.index :status end change_table :blocked_users do |t| t.index :user_id t.index :blocked_user_id end end class User < ActiveRecord::Base has_circle end john = User.create! name: 'john' mary = User.create! name: 'mary' paul = User.create! name: 'paul' john.befriend(mary) john.friends?(mary)
But to be honest, if you do not know what ActiveRecord is, then it seems unbelievable that this stone will solve problems for you. In addition, I would be a little skeptical about this gem, it had a typo during the migration process , so it actually does not work if you do not fix it. This was violated for at least 7 months without fixation. There <800 downloads of a gem, which are few (few users = fewer people find and fix errors), and this does not seem like the author intends to support it.
Well, I just realized what was really going on. It took about 20 minutes to write above, and this may help someone later figure out the problem, so I'm going to leave it. I really suspect that you have a gem in your system called circle, and you have a file, probably in your same directory called circle. Your download path is not set correctly, so when you require 'circle' , it finds the gem, not the file you wrote. The simple answer is to say require File.dirname(__FILE__) + '/circle' instead of require 'circle' This is not a completely correct answer, but it will work without going into the myriad nuances needed to figure out what is right. If you want to find out whatβs the matter, I need to know which version of Ruby you are using, how you intend to use and call this code, and what your directory structure looks like.
Besides. If you said that circle.rb was a file in the same directory, then I would not lose 20 minutes with the top answer. You must provide sufficient context in the future to understand the problem.