Raise error with tip when required ActionView context is missing #229
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
I'm new to Phlex and am submitting this PR to a gotcha that got me. The docs explain that you can render a component by calling
call
on it. Because I had decided to demo Phlex by migrating an existing ERB partial to a Phlex component, I needed to render my new Phlex component from another ERB view. I did this withcall
. (Had I been demoing Phlex by implementing a new view from scratch, I would have copied the docs more directly, which would have led me to userender
.) But usingcall
in this way raised the following error:... from ERB lines such as:
Since my ERB and Phlex components made no direct reference to
default_url_options
, I ended up debugging for a while before realising that the ActionView context is set when you callrender
, so for components which include Rails helpers in this repo, you probably have to render them withrender
, notcall
. This PR shows a helpful error to other people who will make the same mistake:Let me know if you'd like me to change this PR in any way. Thanks for Phlex! Really excited about it.