class ApplicationViewComponent < ViewComponent::Base
include ApplicationHelper
end
class FooComponent < ApplicationViewComponent
end
How can I include not only ApplicationHelper but also user created all helper files in view component?
class ApplicationViewComponent < ViewComponent::Base
include ApplicationHelper
end
class FooComponent < ApplicationViewComponent
end
How can I include not only ApplicationHelper but also user created all helper files in view component?
Use the helpers
proxy instead to access your Rails helpers.
class UserComponent < ViewComponent::Base
def profile_icon
helpers.icon :user
end
end
And use delegate
if you want to simplify the calls:
class UserComponent < ViewComponent::Base
delegate :icon, to: :helpers
def profile_icon
icon :user
end
end
Only include the helper modules when actually needed.