Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support generating views in rails engine #357

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions lib/generators/scenic/model/model_generator.rb
Original file line number Diff line number Diff line change
@@ -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"

Expand Down
3 changes: 2 additions & 1 deletion lib/generators/scenic/view/view_generator.rb
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
require "rails/generators"
require "rails/generators/active_record"
require "scenic"
require "generators/scenic/materializable"

module Scenic
Expand Down Expand Up @@ -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")
Copy link

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. [91/80]

end

def version_regex
Expand Down
2 changes: 1 addition & 1 deletion lib/scenic/definition.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down