-
-
Notifications
You must be signed in to change notification settings - Fork 40
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Raise helpful error when calling a missing rails helper
Co-Authored-By: Seth Horsley <[email protected]>
- Loading branch information
1 parent
16e7ce5
commit 8ba1a69
Showing
3 changed files
with
12 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
module Phlex::Rails::HTML::MethodMissing | ||
def method_missing(name, *args, **kwargs, &block) | ||
return super unless helpers.respond_to?(name) | ||
const_name = name.to_s.gsub("?", "") | ||
module_name = Phlex::Rails::Helpers.constants.find { |mod| mod.to_s.underscore.gsub("domid", "dom_id") == const_name } | ||
return super unless module_name | ||
raise NoMethodError, "Try including `Phlex::Rails::Helpers::#{module_name}` in your class." | ||
end | ||
end |