Skip to content

Add configurable project_path option#104

Open
0000marcell wants to merge 4 commits into
marcoroth:mainfrom
0000marcell:add-project-path-config
Open

Add configurable project_path option#104
0000marcell wants to merge 4 commits into
marcoroth:mainfrom
0000marcell:add-project-path-config

Conversation

@0000marcell
Copy link
Copy Markdown

@0000marcell 0000marcell commented May 16, 2026

This pull request adds support for configuring a custom project path for editor integration in ReActionView, improving flexibility for projects using Docker, monorepos, or non-standard Rails root paths. It also updates documentation and internal logic to use the new configuration, and improves test assertions.

Behavior is the same but now we have the correct path and the link works!

Video showing usage in a docker project:

screenrecording-2026-05-23_15-38-39.mp4

Editor Integration and Project Path Configuration:

  • Added a new project_fullpath configuration option to ReActionView::Config, allowing users to specify a custom project path for "open in editor" links. This is used in place of Rails.root when set. (lib/reactionview/config.rb lib/reactionview/config.rbR8-R21)
  • Updated all usages of the project path in the Herb template handler to use project_fullpath (falling back to Rails.root), including editor links, debug visitors, and meta tags. (lib/reactionview/template/handlers/herb.rb [1] [2] [3] [4]

Documentation Updates:

  • Documented the new project_fullpath option in both the README and installation guide, including practical examples for Docker and monorepos. (README.md [1] docs/docs/installation.md [2]
  • Updated the install generator template to include commented-out configuration for project_fullpath. (lib/generators/reactionview/install_generator.rb lib/generators/reactionview/install_generator.rbR26-R28)

Testing Improvements:

Adds a configurable project_path option to ReActionView that allows customizing the project root path used for editor integration and dev tools.

Motivation

When using ReActionView in environments where the project path differs from Rails.root (e.g., Docker containers with volume mounts, monorepo structures), the dev tools and editor integration may not work correctly. This PR makes the project path configurable.

Changes

  • Added config.project_path attribute to ReActionView::Config
  • Updated Herb handler to use configured path with Rails.root.to_s fallback
  • Applied configured path to:
    • Debug visitor initialization
    • Template filename resolution
    • herb-project-path meta tag
    • local_template? checking
  • Added documentation with usage examples

Usage

# config/initializers/reactionview.rb
ReActionView.configure do |config|
  config.project_path = "/custom/path/to/project"
end

Use Cases

Docker with volume mounts:

# App at /app in container but /Users/you/myapp on host
config.project_path = "/Users/you/myapp"

Monorepo structure:

# Rails app in subdirectory of larger monorepo
config.project_path = File.expand_path("../../", Rails.root)

Testing

All existing tests pass. The change is backwards compatible (defaults to Rails.root.to_s).

@0000marcell 0000marcell marked this pull request as draft May 16, 2026 18:38
@0000marcell 0000marcell force-pushed the add-project-path-config branch from eb2e1c1 to 815df91 Compare May 16, 2026 18:40
- Add config.project_path setting with Rails.root.to_s fallback
- Use configured path in debug visitor, meta tags, and template checking
- Useful for Docker mounts and monorepo structures

💘 Generated with Crush

Assisted-by: Crush:claude-sonnet-4.5
@0000marcell 0000marcell force-pushed the add-project-path-config branch from 815df91 to 00c4d92 Compare May 16, 2026 18:42
@0000marcell 0000marcell marked this pull request as ready for review May 23, 2026 18:43
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant