don't require rails and check for rails defined#319
don't require rails and check for rails defined#319TSMMark wants to merge 2 commits intorails:mainfrom
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. |
|
|
||
| gemspec | ||
|
|
||
| gem "rails", github: "rails/rails" |
There was a problem hiding this comment.
This gem needs to continue being tested with Rails, so this can't be removed.
| 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.
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.
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.
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!