Skip to content

Commit

Permalink
Merge pull request #124 from juanmanuelramallo/122-fix-railtie
Browse files Browse the repository at this point in the history
[#122] Fix railtie
  • Loading branch information
joelhawksley authored Nov 21, 2019
2 parents 038ad46 + bc4631d commit d256b9e
Showing 1 changed file with 9 additions and 5 deletions.
14 changes: 9 additions & 5 deletions lib/action_view/component/railtie.rb
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,14 @@ class Railtie < Rails::Railtie # :nodoc:
end
end

initializer "action_view_component.set_autoload_paths" do |app|
options = app.config.action_view_component

if options.show_previews && options.preview_path
ActiveSupport::Dependencies.autoload_paths << options.preview_path
end
end

initializer "action_view_component.compile_config_methods" do
ActiveSupport.on_load(:action_view_component) do
config.compile_methods! if config.respond_to?(:compile_methods!)
Expand All @@ -44,13 +52,9 @@ class Railtie < Rails::Railtie # :nodoc:

if options.show_previews
app.routes.prepend do
get "/rails/components" => "rails/components#index", :internal => true
get "/rails/components" => "rails/components#index", :internal => true
get "/rails/components/*path" => "rails/components#previews", :internal => true
end

if options.preview_path
ActiveSupport::Dependencies.autoload_paths << options.preview_path
end
end
end
end
Expand Down

0 comments on commit d256b9e

Please sign in to comment.