Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Adds configuration option to disable routes #463

Merged
merged 1 commit into from
Jun 20, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
2 changes: 1 addition & 1 deletion config/routes.rb
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,4 @@
get "recede_historical_location" => "turbo/native/navigation#recede", as: :turbo_recede_historical_location
get "resume_historical_location" => "turbo/native/navigation#resume", as: :turbo_resume_historical_location
get "refresh_historical_location" => "turbo/native/navigation#refresh", as: :turbo_refresh_historical_location
end
end if Turbo.draw_routes
2 changes: 2 additions & 0 deletions lib/turbo-rails.rb
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@
module Turbo
extend ActiveSupport::Autoload

mattr_accessor :draw_routes, default: true

class << self
attr_writer :signed_stream_verifier_key

Expand Down
6 changes: 6 additions & 0 deletions lib/turbo/engine.rb
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,12 @@ class Engine < Rails::Engine
end
end

initializer "turbo.configs" do
config.after_initialize do |app|
Turbo.draw_routes = app.config.turbo.draw_routes != false
end
end

initializer "turbo.helpers", before: :load_config_initializers do
ActiveSupport.on_load(:action_controller_base) do
include Turbo::Streams::TurboStreamsTagBuilder, Turbo::Frames::FrameRequest, Turbo::Native::Navigation
Expand Down