From 5e2eb7eb2d3781c7cf3cb88b5a6eb4295f5dc275 Mon Sep 17 00:00:00 2001 From: Alexey Afrosin Date: Fri, 3 Mar 2023 14:49:18 +0400 Subject: [PATCH 1/5] add custom paths for scenic views --- lib/scenic/definition.rb | 13 ++++++++++++- lib/scenic/version.rb | 2 +- spec/dummy/config/database.yml | 3 +++ 3 files changed, 16 insertions(+), 2 deletions(-) diff --git a/lib/scenic/definition.rb b/lib/scenic/definition.rb index 58195107..9ad7e703 100644 --- a/lib/scenic/definition.rb +++ b/lib/scenic/definition.rb @@ -19,7 +19,18 @@ def full_path end def path - File.join("db", "views", filename) + default_view_path = File.join("db", "views") + view_filename = filename + custom_paths = ActiveRecord::Base.connection_config[:scenic_views_paths] + view_paths = Array(custom_paths) + view_paths = [default_view_path] if view_paths.empty? + + full_view_path = nil + view_paths.each do |path| + full_view_path = File.join(path, view_filename) + break if File.exist?(full_view_path) + end + full_view_path end def version diff --git a/lib/scenic/version.rb b/lib/scenic/version.rb index 4c87f6e7..15c07b90 100644 --- a/lib/scenic/version.rb +++ b/lib/scenic/version.rb @@ -1,3 +1,3 @@ module Scenic - VERSION = "1.7.0".freeze + VERSION = "1.7.1".freeze end diff --git a/spec/dummy/config/database.yml b/spec/dummy/config/database.yml index 5f43185a..aa461f9c 100644 --- a/spec/dummy/config/database.yml +++ b/spec/dummy/config/database.yml @@ -12,3 +12,6 @@ development: &default test: <<: *default database: dummy_test +# set custom paths for scenic views +# scenic_views_paths: +# - '/db/views/postges' From cc804aeddaab696c2f4927788999709ca031625c Mon Sep 17 00:00:00 2001 From: Alexey Afrosin Date: Thu, 27 Apr 2023 17:06:53 +0400 Subject: [PATCH 2/5] add add support active record 7 --- lib/scenic/definition.rb | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/lib/scenic/definition.rb b/lib/scenic/definition.rb index 9ad7e703..cbdb4fdc 100644 --- a/lib/scenic/definition.rb +++ b/lib/scenic/definition.rb @@ -21,7 +21,12 @@ def full_path def path default_view_path = File.join("db", "views") view_filename = filename - custom_paths = ActiveRecord::Base.connection_config[:scenic_views_paths] + # in version7 of ActiveRecord was removed ActiveRecord::Base.connection_config + custom_paths = if ActiveRecord::VERSION < 7 + ActiveRecord::Base.connection_config[:scenic_views_paths] + else + ActiveRecord::Base.connection_db_config.configuration_hash[:scenic_views_paths] + end view_paths = Array(custom_paths) view_paths = [default_view_path] if view_paths.empty? From 93945c5498a5f6086789df4078a6dd0a4a610c27 Mon Sep 17 00:00:00 2001 From: Alexey Afrosin Date: Thu, 27 Apr 2023 17:08:28 +0400 Subject: [PATCH 3/5] change gem version --- lib/scenic/version.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/scenic/version.rb b/lib/scenic/version.rb index 15c07b90..9bfe768c 100644 --- a/lib/scenic/version.rb +++ b/lib/scenic/version.rb @@ -1,3 +1,3 @@ module Scenic - VERSION = "1.7.1".freeze + VERSION = "1.7.2".freeze end From 702e39bff364ccf636d67717ed0cbb7a255e7c41 Mon Sep 17 00:00:00 2001 From: Alexey Afrosin Date: Thu, 27 Apr 2023 17:13:41 +0400 Subject: [PATCH 4/5] fix check version bug --- lib/scenic/definition.rb | 2 +- lib/scenic/version.rb | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/scenic/definition.rb b/lib/scenic/definition.rb index cbdb4fdc..17fa0367 100644 --- a/lib/scenic/definition.rb +++ b/lib/scenic/definition.rb @@ -22,7 +22,7 @@ def path default_view_path = File.join("db", "views") view_filename = filename # in version7 of ActiveRecord was removed ActiveRecord::Base.connection_config - custom_paths = if ActiveRecord::VERSION < 7 + custom_paths = if ActiveRecord::VERSION.MAJOR < 7 ActiveRecord::Base.connection_config[:scenic_views_paths] else ActiveRecord::Base.connection_db_config.configuration_hash[:scenic_views_paths] diff --git a/lib/scenic/version.rb b/lib/scenic/version.rb index 9bfe768c..1372370e 100644 --- a/lib/scenic/version.rb +++ b/lib/scenic/version.rb @@ -1,3 +1,3 @@ module Scenic - VERSION = "1.7.2".freeze + VERSION = "1.7.3".freeze end From 99fffd48db9f5767bcc10360d82b3bf8a6cd8f4a Mon Sep 17 00:00:00 2001 From: Alexey Afrosin Date: Thu, 27 Apr 2023 17:15:03 +0400 Subject: [PATCH 5/5] fix check version bug --- lib/scenic/definition.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/scenic/definition.rb b/lib/scenic/definition.rb index 17fa0367..aa01b686 100644 --- a/lib/scenic/definition.rb +++ b/lib/scenic/definition.rb @@ -22,7 +22,7 @@ def path default_view_path = File.join("db", "views") view_filename = filename # in version7 of ActiveRecord was removed ActiveRecord::Base.connection_config - custom_paths = if ActiveRecord::VERSION.MAJOR < 7 + custom_paths = if ActiveRecord::VERSION::MAJOR < 7 ActiveRecord::Base.connection_config[:scenic_views_paths] else ActiveRecord::Base.connection_db_config.configuration_hash[:scenic_views_paths]