lib/generators/fae/nested_scaffold_generator.rb in fae-rails-2.1.0 vs lib/generators/fae/nested_scaffold_generator.rb in fae-rails-2.2.0

- old
+ new

@@ -19,14 +19,16 @@ inject_concern inject_display_field_to_model inject_model_attachments inject_position_scope inject_parent_info if options.parent_model.present? + inject_polymorphic_info if options.polymorphic end def generate_nested_controller_file @attachments = @@attachments + @polymorphic_name = polymorphic_name template "controllers/nested_scaffold_controller.rb", "app/controllers/#{options.namespace}/#{file_name.pluralize}_controller.rb" end def generate_view_files @form_attrs = set_form_attrs @@ -42,9 +44,20 @@ \n belongs_to :#{options.parent_model.underscore}, touch: true def fae_nested_parent :#{options.parent_model.underscore} end +RUBY + end + end + + def inject_polymorphic_info + inject_into_file "app/models/#{file_name}.rb", after: "BaseModelConcern\n" do <<-RUBY + + def fae_nested_parent + :#{polymorphic_name} + end + RUBY end end end