Class: BaseEditingBootstrap::Generators::FieldOverrideGenerator
- Inherits:
-
Rails::Generators::Base
- Object
- Rails::Generators::Base
- BaseEditingBootstrap::Generators::FieldOverrideGenerator
- Includes:
- BaseEditingBootstrap::GeneratorsHelpers
- Defined in:
- lib/generators/base_editing_bootstrap/field_override/field_override_generator.rb
Constant Summary collapse
- TYPES =
i[base date datetime decimal integer enum boolean]
Instance Method Summary collapse
Instance Method Details
#copy_form_partials ⇒ Object
20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 |
# File 'lib/generators/base_editing_bootstrap/field_override/field_override_generator.rb', line 20 def copy_form_partials if attributes.empty? say "Need one field" else base_path = class_to_view_path(name) attributes.each do |a| attr_name, type = a.split(":") type = :base if type.nil? type = type.to_sym raise "Type #{type} not found in #{TYPES}" unless TYPES.include?(type) copy_file "form_field/_#{type}.html.erb", File.join(*base_path,"form_field", "_#{attr_name}.html.erb") end end end |