Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
S
shotengai
Project
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
open-source
shotengai
Commits
9b70d4da
Commit
9b70d4da
authored
Aug 24, 2017
by
ivan Lan
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add generator for models
parent
0cb021d9
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
37 additions
and
3 deletions
+37
-3
controllers_generator.rb
lib/generators/shotengai/controllers_generator.rb
+5
-2
models_generator.rb
lib/generators/shotengai/models_generator.rb
+31
-0
views_generator.rb
lib/generators/shotengai/views_generator.rb
+1
-1
No files found.
lib/generators/shotengai/controllers_generator.rb
View file @
9b70d4da
...
...
@@ -4,12 +4,15 @@ module Shotengai
module
Generators
class
ControllersGenerator
<
Rails
::
Generators
::
Base
desc
<<-
DESC
.
strip_heredoc
Create inherited
Devise
controllers in your app/controllers folder.
Create inherited
Shotengai
controllers in your app/controllers folder.
Use -n to add the namespec folder, default nil.
Use --produt to custom your own product class
Use --order to custom your own order class
For example:
rails generate
devise
:controllers merchant -n store --product MyProduct --order MyOrder
rails generate
shotengai
:controllers merchant -n store --product MyProduct --order MyOrder
This will create serveral controller classes inherited from merchant product and order class
For example:
...
...
lib/generators/shotengai/models_generator.rb
0 → 100644
View file @
9b70d4da
module
Shotengai
module
Generators
class
ModelsGenerator
<
Rails
::
Generators
::
Base
source_root
File
.
expand_path
(
"../../templates/models"
,
__FILE__
)
desc
<<-
DESC
.
strip_heredoc
Create inhered Shotengai models in your app/model folder.
Use --produt to custom your own product class
Use --order to custom your own order class
For example:
rails g shotengai:models --product MyProduct --order MyOrder
This will create two model file:
create app/models/my_product.rb
create app/models/my_order.rb
DESC
class_option
:product
,
type: :string
,
default:
'Product'
,
desc:
"Product class name"
class_option
:order
,
type: :string
,
default:
'Order'
,
desc:
"Order class name"
def
copy_models
@product_name
,
@order_name
=
options
.
values_at
(
:product
,
:order
)
template
'product.rb'
,
"app/models/
#{
@product_name
.
underscore
}
.rb"
template
'order.rb'
,
"app/models/
#{
@order_name
.
underscore
}
.rb"
end
end
end
end
lib/generators/shotengai/views_generator.rb
View file @
9b70d4da
...
...
@@ -3,7 +3,7 @@ module Shotengai
class
ViewsGenerator
<
Rails
::
Generators
::
Base
source_root
File
.
expand_path
(
"../../templates/views"
,
__FILE__
)
desc
"Copy shotengai views to your application."
desc
"Copy shotengai
example
views to your application."
# hide!
def
copy_views
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment