Sha256: dc49337924a1b8913f6f132157e82d6f203071a6e7e2b3127305a33e78d114f0
Contents?: true
Size: 975 Bytes
Versions: 8
Compression:
Stored size: 975 Bytes
Contents
# frozen_string_literal: true require 'rails/generators/named_base' require 'rails/generators/resource_helpers' module Rails module Generators class JbGenerator < NamedBase # :nodoc: include Rails::Generators::ResourceHelpers source_root File.expand_path('../templates', __FILE__) argument :attributes, type: :array, default: [], banner: 'field:type field:type' def create_root_folder path = File.join('app/views', controller_file_path) empty_directory path unless File.directory?(path) end def copy_view_files template 'index.json.jb', File.join('app/views', controller_file_path, 'index.json.jb') template 'show.json.jb', File.join('app/views', controller_file_path, 'show.json.jb') end private def attributes_names [:id] + super end def attributes_names_with_timestamps attributes_names + %w(created_at updated_at) end end end end
Version data entries
8 entries across 8 versions & 2 rubygems