Skip to content

make namespaced model generation available #25

@itschn

Description

@itschn

Add:

        def create_model
          table_name = name.parameterize('_').tableize
          migration_template 'migration.rb', "db/migrate/create_#{table_name.pluralize}.rb"
          template 'model.rb', "app/models/#{name.singularize}.rb"
        end

in:
https://github.com/HitFox/foxinator-generator/blob/master/lib/generators/foxinator/scaffold/model_generator.rb#L29-L32

the template:
https://github.com/HitFox/foxinator-generator/blob/master/lib/generators/foxinator/scaffold/templates/migration.rb

should be replaced with:

class Create<%= class_name.gsub('::','').pluralize %> < ActiveRecord::Migration

  def change
    create_table :<%= table_name.pluralize %> do |t|
    <%- model_attrs.each do |attr| -%>
      t.<%= attr.type %> :<%= attr.name %>
    <%- end -%>
      t.timestamps
    end
  end

end

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions