Skip to content

Allows you to override the root path directly on a per-instance basis#287

Open
nathanpalmer wants to merge 3 commits intoscenic-views:mainfrom
nathanpalmer:rails-engine
Open

Allows you to override the root path directly on a per-instance basis#287
nathanpalmer wants to merge 3 commits intoscenic-views:mainfrom
nathanpalmer:rails-engine

Conversation

@nathanpalmer
Copy link
Copy Markdown

@nathanpalmer nathanpalmer commented Dec 12, 2019

This helps in situations where you are creating or updating views from within a Rails engine. By adding the root_path to the statement it will be able to correctly find the file.

The , root_path: Database::Engine.root is the part that is manually added. I didn't find any method of autodetecting the rails engine so this would have to be manually added after generating the migration.

Solves the issue I brought up in #261

create_view

create_view :product_stats, version: 2, root_path: Database::Engine.root

update_view

update_view :product_stats, version: 2, revert_to_version: 1, root_path: Database::Engine.root

replace_view

replace_view :product_stats, version: 2, revert_to_version: 1, root_path: Database::Engine.root

Comment thread lib/scenic/statements.rb
# replace_view :engagement_reports, version: 3, revert_to_version: 2
#
def replace_view(name, version: nil, revert_to_version: nil, materialized: false)
def replace_view(name, version: nil, revert_to_version: nil, materialized: false, root_path: Rails.root)
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Lint/UnusedMethodArgument: Unused method argument - revert_to_version.
Metrics/LineLength: Line is too long. [108/80]

Comment thread lib/scenic/statements.rb
# update_view :engagement_reports, version: 3, revert_to_version: 2
#
def update_view(name, version: nil, sql_definition: nil, revert_to_version: nil, materialized: false)
def update_view(name, version: nil, sql_definition: nil, revert_to_version: nil, materialized: false, root_path: Rails.root)
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Metrics/ParameterLists: Avoid parameter lists longer than 5 parameters. [6/5]
Lint/UnusedMethodArgument: Unused method argument - revert_to_version.
Metrics/LineLength: Line is too long. [128/80]

Comment thread lib/scenic/statements.rb
# SQL
#
def create_view(name, version: nil, sql_definition: nil, materialized: false)
def create_view(name, version: nil, sql_definition: nil, materialized: false, root_path: Rails.root)
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Metrics/LineLength: Line is too long. [104/80]

@derekprior derekprior changed the base branch from master to main June 18, 2020 15:03
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants