Sha256: 1fcada41b109aa50cd8c465303fcdd35b0830d0e72ff4600f1a78c62017e55b3
Contents?: true
Size: 1.38 KB
Versions: 2
Compression:
Stored size: 1.38 KB
Contents
require "rails" require "spine/generators" module Spine module Generators class ScaffoldGenerator < Base source_root File.expand_path("../templates", __FILE__) desc "Generate a Spine scaffold with configured fields" argument :fields, desc: "List of model attributes", type: :array, banner: "field1 field2" def create_scaffold raise("The 'eco' gem is required; add it to the Gemfile") unless defined?(::Eco) generate "spine:model #{model_name} #{fields.join(" ")} --app #{app_name}" template "controller.coffee.erb", "app/assets/javascripts/#{app_name}/controllers/#{controller_name}.js.coffee" template "edit.jst.erb", "app/assets/javascripts/#{app_name}/views/#{controller_name}/edit.jst.eco" template "index.jst.erb", "app/assets/javascripts/#{app_name}/views/#{controller_name}/index.jst.eco" template "new.jst.erb", "app/assets/javascripts/#{app_name}/views/#{controller_name}/new.jst.eco" template "show.jst.erb", "app/assets/javascripts/#{app_name}/views/#{controller_name}/show.jst.eco" end protected def model_name file_name.singularize end def model_class class_name.singularize end def controller_name file_name.pluralize end def controller_class class_name.pluralize end end end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
spine-rails-0.1.2 | lib/generators/spine/scaffold/scaffold_generator.rb |
spine-rails-0.1.1 | lib/generators/spine/scaffold/scaffold_generator.rb |