Class: Rails::NextRailsScaffoldGenerator
- Inherits:
-
Generators::NamedBase
- Object
- Generators::NamedBase
- Rails::NextRailsScaffoldGenerator
- Includes:
- NextRailsScaffold::Actions
- Defined in:
- lib/generators/rails/next_rails_scaffold/next_rails_scaffold_generator.rb
Constant Summary collapse
- NODE_REQUIRED_VERSION =
">= 18.18.0"
- YARN_VERSION =
"4.5.3"
- NEXT_VERSION =
"15.0.3"
Instance Method Summary collapse
-
#add_resource_route ⇒ Object
Properly nests namespaces passed into a generator.
-
#create_frontend_project ⇒ Object
Check Javascript depencies and create a new Next.js project.
-
#initialize(args, *options) ⇒ NextRailsScaffoldGenerator
constructor
:nodoc:.
Methods included from NextRailsScaffold::Actions
Constructor Details
#initialize(args, *options) ⇒ NextRailsScaffoldGenerator
:nodoc:
15 16 17 18 |
# File 'lib/generators/rails/next_rails_scaffold/next_rails_scaffold_generator.rb', line 15 def initialize(args, *) # :nodoc: super self.attributes = shell.base.attributes end |
Instance Method Details
#add_resource_route ⇒ Object
Properly nests namespaces passed into a generator
$ bin/rails generate resource admin/users/products
should give you
scope '/api' do
namespace :admin do
namespace :users do
resources :products
end
end
end
33 34 35 36 37 |
# File 'lib/generators/rails/next_rails_scaffold/next_rails_scaffold_generator.rb', line 33 def add_resource_route return if [:actions].present? route "resources :#{file_name.pluralize}", namespace: regular_class_path, scope: "/api" end |
#create_frontend_project ⇒ Object
Check Javascript depencies and create a new Next.js project. Install the the usefull packages and create the scaffold code for frontend application.
41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 |
# File 'lib/generators/rails/next_rails_scaffold/next_rails_scaffold_generator.rb', line 41 def create_frontend_project return say_status :remove, "skip frontend folder", :yellow if shell.base.behavior == :revoke check_node! append_gitignore! empty_directory "frontend" inside("frontend") do create_next_app! install_hygen! run("npx hygen scaffold javascript #{name} #{mapped_attributes.join(" ")}") run("yarn build") end end |