{"id":15619846,"url":"https://github.com/nedomas/databound","last_synced_at":"2025-04-07T05:15:46.852Z","repository":{"id":22269877,"uuid":"25604071","full_name":"Nedomas/databound","owner":"Nedomas","description":"Provides Javascript a simple API to the Ruby on Rails CRUD.","archived":false,"fork":false,"pushed_at":"2015-04-11T12:32:30.000Z","size":695,"stargazers_count":455,"open_issues_count":3,"forks_count":11,"subscribers_count":18,"default_branch":"master","last_synced_at":"2025-03-30T19:07:15.166Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"","language":"CoffeeScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/Nedomas.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2014-10-22T20:58:03.000Z","updated_at":"2024-12-06T21:15:31.000Z","dependencies_parsed_at":"2022-08-20T02:20:07.778Z","dependency_job_id":null,"html_url":"https://github.com/Nedomas/databound","commit_stats":null,"previous_names":[],"tags_count":4,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Nedomas%2Fdatabound","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Nedomas%2Fdatabound/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Nedomas%2Fdatabound/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Nedomas%2Fdatabound/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/Nedomas","download_url":"https://codeload.github.com/Nedomas/databound/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":247595335,"owners_count":20963943,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-10-03T08:42:03.991Z","updated_at":"2025-04-07T05:15:46.446Z","avatar_url":"https://github.com/Nedomas.png","language":"CoffeeScript","readme":"[![Gem](https://img.shields.io/gem/v/databound.svg?style=flat-square)](https://rubygems.org/gems/databound)\n[![Bower](https://img.shields.io/bower/v/databound.svg?style=flat-square)](http://bower.io/search/?q=databound)\n[![npm](https://img.shields.io/npm/v/databound.svg?style=flat-square)](https://www.npmjs.com/package/databound)\n[![Code Climate](http://img.shields.io/codeclimate/github/Nedomas/databound.svg?style=flat-square)](https://codeclimate.com/github/Nedomas/databound)\n[![Build Status](http://img.shields.io/travis/Nedomas/databound.svg?style=flat-square)](https://travis-ci.org/Nedomas/databound)\n\n![Databound](https://cloud.githubusercontent.com/assets/1877286/4743542/df89dcec-5a28-11e4-9114-6f383fe269cb.png)\n\nProvides Javascript a simple CRUD API to the Ruby on Rails backend.\n\n**Check out live examples on the Databound website** [databound.me](http://databound.me).\n\n**Backend gem repo** [github.com/Nedomas/databound-rails](http://github.com/Nedomas/databound-rails).\n\n## Usage\n\n```js\n  User = new Databound('/users')\n\n  User.where({ name: 'John' }).then(function(users) {\n    alert('Users called John');\n  });\n\n  User.find(15).then(function(user) {\n    alert('User no. 15: ' + user.name);\n  });\n\n  User.create({ name: 'Peter' }).then(function(user) {\n    alert('I am ' + user.name + ' from database');\n  });\n```\n\n[More API docs](http://nedomas.github.io/databound/src/databound.html)\n\n## Version support and dependencies\n\nWorks with:\n- Ruby on Rails **3+**\n- Ruby **2.0+**\n- It can work with **Angular** as a better **ngResource** alternative\n- [Rails API](https://github.com/rails-api/rails-api)\n- ActiveRecord or Mongoid\n- [Active Model Serializers](https://github.com/rails-api/active_model_serializers)\n- Chrome **any**, Firefox **any**, Opera **any**, IE **8+**\n\nDepends on:\n- Lodash (should work with any version)\n- jQuery **1.5+**\n\njQuery is used for making requests and promises. \nYou can use your own library instead. Read [API docs](http://nedomas.github.io/databound/src/databound.html) on how to override those.\n\n## Installation\n\n**1 - Gemfile**\n```ruby\ngem 'databound', '3.1.3'\n```\n\n**2.1 - With asset pipeline (sprockets)**\n\nRun generator to add Databound to application.js\n```sh\nrails g databound:install\n```\n\n**2.2 - Without asset pipeline**\n\nDownload the [databound-standalone.js](https://raw.githubusercontent.com/Nedomas/databound/master/dist/databound-standalone.js) and load it up\n```html\n\u003cscript src='assets/databound-standalone.js'\u003e\u003c/script\u003e\n```\n\n**2.3 - With require.js**\n\nDownload Javascript part with [npm](http://npmjs.com) or [bower](bower.io)\n\n```sh\nnpm install databound\n```\n\nOR\n\n```sh\nbower install databound\n```\n\nRequire it Javascript with:\n```javascript\nvar Databound = require('databound');\n```\n\n**3 - Add a route to config/routes.rb**\n```ruby\nRails.application.routes.draw do\n  databound :users, columns: [:name, :city]\nend\n```\n\n**4 - *(optional)* Controller is autogenerated from route**\n\nBut if you already have a controller, you can include Databound and specify the model yourself.\n```ruby\nclass UsersController \u003c ApplicationController\n  databound do\n    model :user\n    columns :name, :city\n  end\nend\n```\n\n**5 - Install dependencies (skip if with ``require.js``)**\n\nEasiest way is to use the official Ruby gems or include them from CDNs.\n\n**Lo-Dash** - [lodash-rails gem](https://github.com/rh/lodash-rails) or [CDN](http://cdnjs.com/libraries/lodash.js).\n\n**jQuery** *(already installed by default on Rails)* - [jquery-rails gem](https://github.com/rails/jquery-rails) or [CDN](https://code.jquery.com)\n\n**6 - Use it in the Javascript**\n```javascript\nvar User = new Databound('/users');\n```\n\n## Security\n\n**Which parts can Javascript modify?**\n\nSpecify ``columns``.\n\nBy default - no columns are modifiable.\n\n**How to secure the relation values?**\n\nYou can use ``dsl(:your_column, :expected_value)`` to only allow certain dsl values and convert them to relation ids in the backend.\n\n**How to protect the scope of the records?**\n\nIf you need a reference to the record being modified, use ``permit``. It will give you a parsed record.\n\nIt also works with 3rd party libraries.\n\n```ruby\nclass ProjectsController \u003c ApplicationController\n  databound do\n    model :project\n    columns :name, :city\n\n    # CanCanCan gem\n    permit(:create) do\n      authorize! :create, current_user\n    end\n\n    # Pundit\n    permit(:update) do\n      authorize current_user\n    end\n\n    # Plain Ruby\n    permit(:destroy) do\n      current_user.god?\n    end\n  end\nend\n```\n\n**Which parts can Javascript show?**\n\nUse [Active Model Serializers](https://github.com/rails-api/active_model_serializers) to serialize the record.\n\nIf you don't want to use that, you can overwrite ``as_json`` method on the model.\n\n## Contributing :heart:\n\n1. Fork it\n2. Create your feature branch (git checkout -b my-new-feature)\n3. Commit your changes (git commit -am 'Add some feature')\n4. Push to the branch (git push origin my-new-feature)\n5. Create a new Pull Request\n6. Get ice cream :ice_cream:\n\n## Changelog\n\n**Next release**\n\n* Associations.\n* Your contribution here.\n\n**3.1.3** - 2015-04-10\n* Fix Postgresql bug introduced with ``3.1.2``. Do it [@remigijusj](https://github.com/remigijusj) ``bind_values`` way.\n\n**3.1.2** - 2015-04-10\n* Fix bug introduced with Rails 4.2 ``AdequateRecord`` update - AREL query API changed. Thanks to [@remigijusj](https://github.com/remigijusj) who patched it (https://github.com/Nedomas/databound-rails/issues/2).\n\n**3.1.1** - 2015-02-10\n* Fix ``where`` bug which did to take into account the ``extra_where_scopes``.\n\n**3.1.0** - 2015-01-10\n* Friendly error messages in development environment.\n* ``.all`` method.\n\n**3.0.3** - 2015-01-09\n* Fix bootup of a default Rails stack in production with ``databound`` and ``eager_load``\n\n**3.0.2** - 2015-01-08\n* ``read`` action of ``permit`` returning ``false`` now returns empty scoped records\n\n**3.0.1** - 2015-01-08\n* Minor bugfix\n\n**3.0.0** - 2015-01-08\n\n* Simplify configuration setup and improve performance.\n* Thanks to [@Austio](https://github.com/Austio) for docs on 3rd party authentication libraries.\n\n```ruby\nclass ProjectsController \u003c ApplicationController\n  databound do\n    model :project\n    columns :name, :city\n  end\nend\n```\n\n**2.0.1** - 2015-01-03\n\n* Add support for specifying ``permitted_columns`` in ``routes.rb``. No columns are modifiable by default.\n\n**1.1.0** - 2015-01-03\n\n* You can specify ``permit_update_destroy?`` on a controller to manage the scope of the records that can be modified from the Javascript.\n\n**1.0.0** - 2015-01-03\n\n* Destroy now accepts ``id`` instead of ``{ id: someid }``.\n* ``extra_find_scopes`` renamed to ``extra_where_scopes``\n\n## Used and sponsored by\n\n[![closeheat](https://cloud.githubusercontent.com/assets/1877286/7101371/363a6d22-e057-11e4-918b-dee71676d16b.png)](http://closeheat.com)\n[![SameSystem](https://cloud.githubusercontent.com/assets/1877286/5602104/d8e44986-933f-11e4-8e64-b0c8e83a94d1.jpg)](http://samesystem.com) [![picnic-right](https://cloud.githubusercontent.com/assets/1877286/5602105/dab01272-933f-11e4-9aab-624ba81825d9.png)](http://spacepicnic.net)\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fnedomas%2Fdatabound","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fnedomas%2Fdatabound","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fnedomas%2Fdatabound/lists"}