Skip to content

Instantly share code, notes, and snippets.

@damoiser
Created August 7, 2015 07:18
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save damoiser/a0ef124a5ba1aee78135 to your computer and use it in GitHub Desktop.
Save damoiser/a0ef124a5ba1aee78135 to your computer and use it in GitHub Desktop.
Rails 4.2.2 wrong computed class type
unless File.exist?('Gemfile')
File.write('Gemfile', <<-GEMFILE)
source 'https://rubygems.org'
gem 'rails'
gem 'arel'
gem 'rack'
gem 'i18n'
gem 'pry-rails'
gem 'sqlite3'
GEMFILE
system 'bundle'
end
require 'bundler'
Bundler.setup(:default)
require 'active_record'
require 'minitest/autorun'
require 'logger'
# This connection will do for database-independent bug reports.
ActiveRecord::Base.establish_connection(adapter: 'sqlite3', database: ':memory:')
ActiveRecord::Base.logger = Logger.new(STDOUT)
ActiveRecord::Schema.define do
create_table :servers do |t|
end
create_table :local_drives do |t|
end
end
class LocalDrive < ActiveRecord::Base
end
class Server < ActiveRecord::Base
has_many :local_drives
end
class BugTest < Minitest::Test
def test_habtm_reflections_with_nonstandard_name_and_class_name_option_work_correctly
server = Server.create!
server.local_drives << LocalDrive.create!
# here you'll have the error
# NameError: uninitialized constant Server::LocalDrife
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment