Coder Social home page Coder Social logo

formify_rails's Introduction

Formify Rails

A boilerplate generator that uses ejs to produce a redux-saga CRUD based on the database structure of any rails API that uses postgresql.

Introduction

Are you tired of manually coding every single form in your React components? Now you can generate them automatically. Formify detects the structure of your database and generates the necessary forms based on the tables and fields. You can then add or remove details from the generated boilerplate to fit your needs.

Getting started

git clone the repo, cd to it and:

  1. $ npm install
  2. $ cd src/scripts
  3. Make sure postgresql.json contains your database credentials.
  4. $ ./generate.sh
  5. $ npm start

This should generate all the necessary forms based on the postgresql.json database. To use a different database name or credentials, modify the postgresql.json file.

Example

For example, a database from a rails API with the following schema.rb:

ActiveRecord::Schema.define(version: 2021_09_07_212158) do

  # These are extensions that must be enabled in order to support this database
  enable_extension "plpgsql"

  create_table "testtypes", force: :cascade do |t|
    t.binary "binary"
    t.boolean "boolean"
    t.date "date"
    t.datetime "datetime"
    t.decimal "decimal"
    t.float "float"
    t.integer "integer"
    t.string "string"
    t.text "text"
    t.time "time"
    t.datetime "timestamp"
    t.datetime "created_at", precision: 6, null: false
    t.datetime "updated_at", precision: 6, null: false
  end

end

Will generate the following form through the /src/components/testtypes_form.json "form object" file:

Example of a generated form

This form object is then loaded to the CRUD components in /src/components/. For a better understanding of how these form objects work, visit the react-jsonschema-form playground, as well as their docs.

Testing

You can test the CRUD against formify_rails_api. It's a typical unsecured Rails API with the schema.rb from the example in this README.

Development

For more details about how the data pipeline from rails to react works, check out this experimental draft:

https://gist.github.com/voscarmv/cf4b126eed800a087d2f20a15f04265a

ToDo

  • Complete Sagas CRUD.
  • Debug formify.js to produce working code.
  • Automate database structure extraction.
  • Automate component generation and file distribution.
  • Add Ui styles to forms.
  • Secure with JWT (devise-jwt)

formify_rails's People

Contributors

voscarmv avatar

Stargazers

 avatar

Watchers

 avatar  avatar

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.