This repository has been archived on 2021-11-24. You can view files and clone it, but cannot push or open issues or pull requests.
phone_app/lib/generators/rails/qis/qis_generator.rb
2021-08-23 10:26:02 +02:00

59 lines
1.6 KiB
Ruby

#QisGenerator v 0.6
class Rails::QisGenerator < Rails::Generators::NamedBase
source_root File.expand_path('templates', __dir__)
include Rails::Generators::ModelHelpers
argument :attributes, type: :array, default: [], banner: "field[:type][:index] field[:type][:index]"
include Rails::Generators::ResourceHelpers
def create_views_files
template "_class.html.haml", File.join("app/views", "admin", plural_name, "_#{singular_name}.html.haml")
template "_form.html.haml", File.join("app/views", "admin", plural_name, "_form.html.haml")
template "create.js.erb", File.join("app/views", "admin", plural_name, "create.js.erb")
template "destroy.js.erb", File.join("app/views", "admin", plural_name, "destroy.js.erb")
template "edit.js.erb", File.join("app/views", "admin", plural_name, "edit.js.erb")
template "index.html.haml", File.join("app/views", "admin", plural_name, "index.html.haml")
template "new.js.erb", File.join("app/views", "admin", plural_name, "new.js.erb")
template "show.html.haml", File.join("app/views", "admin", plural_name, "show.html.haml")
template "update.js.erb", File.join("app/views", "admin", plural_name, "update.js.erb")
route "namespace :admin do
resources :#{plural_name} do
member do
end
collection do
end
end
end
"
end
def create_controller_file
template "controller.rb", File.join("app/controllers", "admin", "#{controller_file_name}_controller.rb")
end
def run_other_generators
invoke "rails:model"
end
end
# V 0.1