GithubHelp home page GithubHelp logo

yaocanwei / cudify Goto Github PK

View Code? Open in Web Editor NEW

This project forked from tsaikoga/cudify

0.0 2.0 0.0 124 KB

The gem that can help you create, update or delete records at once.

License: MIT License

cudify's Introduction

Cudify

It's convinient for you.

This gem can help you quickly create, update or delete the records.

And it also supports accept_nested_attributes, for examples.

Installation

Add this line to your application's Gemfile:

gem 'cudify'

And then execute:

$ bundle

Or install it yourself as:

$ gem install cudify

Usage

Firstly, it must add require cudify to your enviroment(in config/environment.rb):

require "cudify"

This gem can help you quickly create, update or delete the records(you can try it by console), if you follow the rule below:

###CREATE RECORDS: You just use the ActiveRecord method cudify or cudify!, the parameters is like the original records example:

	User.cudify!(name: "TsaiKoga", sex: "man", age: 23)

###DESTROY RECORDS: If you want to destroy records, the first thing is you need to know their ids, and set hash like them below: example:

	User.cudify!(id:1, name:"TsaiKoga", _destroy: 1)
	User.cudify!([{id:1, name:"TsaiKoga", _destroy: 1}, {id:2, _destroy: 1}])

Remember: the symbol _destroy is important!

###UPDATE RECORDS: If you want to update records, you must know their ids and put them into hash. example:

	User.cudify!(name: "CKJ", sex: "man")

It also supports accept_nested_attributes, for examples:( user has many appliances )

###CREATE RECORDS WITH ACCEPT NESTED ATTRIBUTES:

User.cudify!({name: "TsaiKoga", sex: "man", age: 23, appliances_attributes: [{name: "labtop", price: 4300.0}, {name: "pen", price: 5}]})

Contributing

  1. Fork it
  2. Create your feature branch (git checkout -b my-new-feature)
  3. Commit your changes (git commit -am 'Add some feature')
  4. Push to the branch (git push origin my-new-feature)
  5. Create new Pull Request

cudify's People

Contributors

tsaikoga 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.