diff --git a/lib/generators/scenic/model/model_generator.rb b/lib/generators/scenic/model/model_generator.rb index b04e4186..6afa75f6 100644 --- a/lib/generators/scenic/model/model_generator.rb +++ b/lib/generators/scenic/model/model_generator.rb @@ -1,5 +1,6 @@ require "rails/generators" require "rails/generators/rails/model/model_generator" +require "scenic" require "generators/scenic/view/view_generator" require "generators/scenic/materializable" diff --git a/lib/generators/scenic/view/view_generator.rb b/lib/generators/scenic/view/view_generator.rb index 496035f8..30d68029 100644 --- a/lib/generators/scenic/view/view_generator.rb +++ b/lib/generators/scenic/view/view_generator.rb @@ -1,5 +1,6 @@ require "rails/generators" require "rails/generators/active_record" +require "scenic" require "generators/scenic/materializable" module Scenic @@ -80,7 +81,7 @@ def file_name end def views_directory_path - @views_directory_path ||= Rails.root.join("db", "views") + @views_directory_path ||= (Rails.root || Pathname.new(Dir.pwd)).join("db", "views") end def version_regex diff --git a/lib/scenic/definition.rb b/lib/scenic/definition.rb index 58195107..10bd7b73 100644 --- a/lib/scenic/definition.rb +++ b/lib/scenic/definition.rb @@ -15,7 +15,7 @@ def to_sql end def full_path - Rails.root.join(path) + (Rails.root || Pathname.new(Dir.pwd)).join(path) end def path