Skip to content

Commit

Permalink
Update method_missing.rb
Browse files Browse the repository at this point in the history
Co-Authored-By: Seth Horsley <[email protected]>
  • Loading branch information
joeldrapper and SethHorsley committed Mar 17, 2024
1 parent 8ba1a69 commit 90d50b0
Showing 1 changed file with 4 additions and 0 deletions.
4 changes: 4 additions & 0 deletions lib/phlex/rails/html/method_missing.rb
Original file line number Diff line number Diff line change
@@ -1,9 +1,13 @@
# frozen_string_literal: true

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

0 comments on commit 90d50b0

Please sign in to comment.