-
Notifications
You must be signed in to change notification settings - Fork 177
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
don't require rails and check for rails defined #319
base: main
Are you sure you want to change the base?
Conversation
Damn, so some other gems required by this gem also define a This is really unfortunate because many gems check to see if we're in a "Rails app" by checking EDIT: |
Alright so I was able to get this working properly by forking 3 other gems and fixing their E.g. |
@@ -6,7 +6,7 @@ git_source(:github) { |repo| "https://github.com/#{repo}.git" } | |||
|
|||
gemspec | |||
|
|||
gem "rails", github: "rails/rails" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This gem needs to continue being tested with Rails, so this can't be removed.
@@ -50,7 +50,7 @@ def guess_the_first_application_binding | |||
@bindings.find do |binding| | |||
source_location = SourceLocation.new(binding) | |||
source_location.path.to_s.start_with?(Rails.root.to_s) | |||
end | |||
end if defined?(Rails.root) && Rails.root |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't think this change should be made like this. We should be configuring the application path, and using the Railtie we can set it to Rails.root
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Rails.root
is not a method in my case. Would you prefer just checking for the method
end if defined?(Rails.root) && Rails.root | |
end if defined?(Rails.root) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No. I'd prefer if this class didn't call Rails.root
at all, and instead had a application_root
configuration that could be set by this gem Railtie
to ExceptionMapper.application_root = Rails.root
Hi, this gem is awesome! So awesome that I wanted to use it in vanilla Ruby projects as well, and not only Rails projects.
This PR resolves all of the issues I faced when running this outside of a Rails-app environment.
Thank you!