Skip to content

Commit ba526bc

Browse files
committed
Fix support for rails engines/plugins
See here for a description of the problem: #144 (comment) The solution is to make the application_id depend on the *project* root rather than the *application* root, since only the server can know the correct application root.
1 parent 2f8f8c7 commit ba526bc

File tree

3 files changed

+13
-3
lines changed

3 files changed

+13
-3
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@
2323
cause spring to simply quit, meaning that you'd incur the full startup
2424
penalty on the next run. Now spring doesn't quit, and will try to load
2525
up your new bundle in the background.
26+
* Fix support for using spring with Rails engines/plugins
2627

2728
## 1.0.0
2829

lib/spring/configuration.rb

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,15 +22,24 @@ def verify_environment
2222

2323
def application_root_path
2424
@application_root_path ||= begin
25-
path = Pathname.new(File.expand_path(application_root || find_project_root))
25+
if application_root
26+
path = Pathname.new(File.expand_path(application_root))
27+
else
28+
path = project_root_path
29+
end
30+
2631
raise MissingApplication.new(path) unless path.join("config/application.rb").exist?
2732
path
2833
end
2934
end
3035

36+
def project_root_path
37+
@project_root_path ||= find_project_root(Pathname.new(File.expand_path(Dir.pwd)))
38+
end
39+
3140
private
3241

33-
def find_project_root(current_dir = Pathname.new(Dir.pwd))
42+
def find_project_root(current_dir)
3443
if current_dir.join(gemfile).exist?
3544
current_dir
3645
elsif current_dir.root?

lib/spring/env.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ def tmp_path
3333
end
3434

3535
def application_id
36-
Digest::MD5.hexdigest(root.to_s)
36+
Digest::MD5.hexdigest(Spring.project_root_path.to_s)
3737
end
3838

3939
def socket_path

0 commit comments

Comments
 (0)