{"record":{"id":"9885447f088691b4","repo":"ViewComponent/view_component","slug":"component-preview-params-path-not-found","errorCode":null,"errorMessage":"Component preview '#{params[:path]}' not found.","messagePattern":"Component preview '#(.+?)' not found\\.","errorType":"http","errorClass":"AbstractController::ActionNotFound","httpStatus":404,"severity":"error","filePath":"app/controllers/concerns/view_component/preview_actions.rb","lineNumber":70,"sourceCode":"\n    # :doc:\n    def previews_enabled?\n      ViewComponent::Base.config.previews.enabled\n    end\n\n    # :doc:\n    def find_preview\n      candidates = []\n      params[:path].to_s.scan(%r{/|$}) { candidates << Regexp.last_match.pre_match }\n      preview = candidates.sort_by(&:length).reverse_each.detect { |candidate| ViewComponent::Preview.exists?(candidate) }\n\n      if preview\n        @preview = ViewComponent::Preview.find(preview)\n      else\n        # TODO: This branch is covered in #test_returns_404_when_preview_does_not_exist,\n        # but Simplecov doesn't always mark it as covered.\n        # :nocov:\n        raise AbstractController::ActionNotFound, \"Component preview '#{params[:path]}' not found.\"\n        # :nocov:\n      end\n    end\n\n    def set_locale(&block)\n      I18n.with_locale(params[:locale] || I18n.default_locale, &block)\n    end\n\n    # Returns either {} or {layout: value} depending on configuration\n    def determine_layout(layout_override = nil, prepend_views: true)\n      return {} unless defined?(Rails.root)\n\n      layout_declaration = {}\n\n      if !layout_override.nil?\n        # Allow component-level override, even if false (thus no layout rendered)\n        layout_declaration[:layout] = layout_override\n      elsif default_preview_layout.present?","sourceCodeStart":52,"sourceCodeEnd":88,"githubUrl":"https://github.com/ViewComponent/view_component/blob/9f22c36fa7d7b44098a8ed97472e3b4674ae420f/app/controllers/concerns/view_component/preview_actions.rb#L52-L88","documentation":"Error \"Component preview '#{params[:path]}' not found.\" thrown in ViewComponent/view_component.","triggerScenarios":"Thrown at app/controllers/concerns/view_component/preview_actions.rb:70 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Verify the preview path matches a file in the configured preview paths (config.view_component.preview_paths): the file must be named *_preview.rb and the lookup path is the file name without that suffix.","Add the preview's directory to config.view_component.preview_paths in config/environments/development.rb (or test.rb) if using a custom location.","Restart the server after adding new preview files or paths; in eager-loaded environments new previews are not discovered at runtime."],"exampleFix":null,"handlingStrategy":null,"validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"9f22c36fa7d7b44098a8ed97472e3b4674ae420f","analyzedAt":"2026-08-23T10:20:47.008Z","schemaVersion":2},"datasetVersion":"2026-08-23T13:39:53.451Z"}