lib/action_view/component/railtie.rb in actionview-component-1.5.0 vs lib/action_view/component/railtie.rb in actionview-component-1.5.1
- old
+ new
@@ -25,10 +25,18 @@
ActiveSupport.on_load(:action_view_component) do
options.each { |k, v| send("#{k}=", v) }
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!)
end
end
@@ -42,15 +50,11 @@
config.after_initialize do |app|
options = app.config.action_view_component
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
end