Giter Club home page Giter Club logo

microgen's Introduction

Microgen

This is a collection of very simple generators for Rails 3/4. So far, there are only generators for migrations - to create new tables and to change existing tables.

These generators don't load a Rails environment or attempt to boot Rails at all, they simply write a static file with a proper migration name and a lot of commented out example code to perform all the common operations. You can then uncomment and edit what you need and remove the rest.

I find this to be a faster and more useful approach than trying to define my migration on the command line and then having to edit it and look up references anyway.

I put these and other useful scripts in an 'aux' directory in my Rails projects, which I link to a dropbox folder and never commit. Then I can run them like so:

./aux/table_generator Person

The result:

Generated: db/migrate/20140331090600_create_people.rb

Then the migration will look something like this:

class CreatePeople < ActiveRecord::Migration
  def change
    create_table :people do |t|
      #t.references   :anything
      #t.belongs_to   :order,             index: true

      #t.datetime     :published_at
      #t.string       :source_reference,  length: 30
      #t.string       :state,             null: false
      #t.float        :pressure,          default: 0.0
      #t.string       :email,             unique: true

      t.timestamps
    end
  end
end

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.