Commit 9b70d4da by ivan Lan

Add generator for models

parent 0cb021d9
......@@ -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:
......
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
......@@ -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
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment