app/controllers/lookbook/previews_controller.rb in lookbook-0.8.0.beta.0 vs app/controllers/lookbook/previews_controller.rb in lookbook-0.8.0

- old
+ new

@@ -45,10 +45,13 @@ if @example @preview = @example.preview if params[:path] == @preview&.lookup_path redirect_to show_path "#{params[:path]}/#{@preview.default_example.name}" end + else + first_example = Lookbook.previews.find(params[:path])&.examples&.first + redirect_to show_path(first_example.lookup_path) if first_example end end def set_title @title = @example.present? ? [@example&.label, @preview&.label].compact.join(" :: ") : "Not found" @@ -141,12 +144,11 @@ } } end def preview_controller - return @preview_controller if @preview_controller.present? - controller_class = Lookbook.config.preview_controller.constantize - controller = controller_class.new + return @preview_controller if @preview_controller + controller = Lookbook::Engine.preview_controller.new controller.request = request controller.response = response @preview_controller ||= controller end