Skip to content

Instantly share code, notes, and snippets.

@willnet
Created July 13, 2017 01:32
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 willnet/b31b7ddc354aa60f2850ff274879b625 to your computer and use it in GitHub Desktop.
Save willnet/b31b7ddc354aa60f2850ff274879b625 to your computer and use it in GitHub Desktop.
begin
require "bundler/inline"
rescue LoadError => e
$stderr.puts "Bundler version 1.10 or later is required. Please update your Bundler"
raise e
end
gemfile(true) do
source "https://rubygems.org"
# Activate the gem you are reporting the issue against.
gem "rails", "5.1.2"
gem "activerecord", "5.1.2"
gem "sqlite3"
end
require "active_record"
require "minitest/autorun"
require "logger"
# Ensure backward compatibility with Minitest 4
Minitest::Test = MiniTest::Unit::TestCase unless defined?(Minitest::Test)
# 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 :posting_posts, force: true do |t|
end
create_table :posting_comments, force: true do |t|
t.references :posts
end
end
module Posting
class Engine < ::Rails::Engine
isolate_namespace Posting
end
end
module Posting
class Post < ActiveRecord::Base
has_many :comments
end
class Comment < ActiveRecord::Base
belongs_to :post
end
end
class BugTest < Minitest::Test
def test_association_stuff
post = Posting::Post.create!
post.comments << Posting::Comment.create!
assert_equal 1, post.comments.count
assert_equal 1, Posting::Comment.count
assert_equal post.id, Posting::Comment.first.post.id
end
end
@willnet
Copy link
Author

willnet commented Jul 13, 2017

/Users/willnet/.rbenv/versions/2.4.1/lib/ruby/gems/2.4.0/gems/railties-5.1.2/lib/rails/engine.rb:670:in `find_root_with_flag': Could not find root path for Posting::Engine (RuntimeError)
	from /Users/willnet/.rbenv/versions/2.4.1/lib/ruby/gems/2.4.0/gems/railties-5.1.2/lib/rails/engine.rb:371:in `find_root'
	from /Users/willnet/.rbenv/versions/2.4.1/lib/ruby/gems/2.4.0/gems/railties-5.1.2/lib/rails/engine.rb:540:in `config'
	from /Users/willnet/.rbenv/versions/2.4.1/lib/ruby/gems/2.4.0/gems/railties-5.1.2/lib/rails/engine.rb:533:in `routes'
	from /Users/willnet/.rbenv/versions/2.4.1/lib/ruby/gems/2.4.0/gems/railties-5.1.2/lib/rails/railtie.rb:185:in `public_send'
	from /Users/willnet/.rbenv/versions/2.4.1/lib/ruby/gems/2.4.0/gems/railties-5.1.2/lib/rails/railtie.rb:185:in `method_missing'
	from /Users/willnet/.rbenv/versions/2.4.1/lib/ruby/gems/2.4.0/gems/railties-5.1.2/lib/rails/engine.rb:383:in `isolate_namespace'
	from mountable_engine_foreign_key.rb:38:in `<class:Engine>'
	from mountable_engine_foreign_key.rb:37:in `<module:Posting>'
	from mountable_engine_foreign_key.rb:36:in `<main>'

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment