Sha256: bd5a7a24fcb90742f9a7c47d576ecd1f12939f9864d3e190dc76f8fa21e85a17

Contents?: true

Size: 1.61 KB

Versions: 1

Compression:

Stored size: 1.61 KB

Contents

# Jibe

Jibe keeps simple data 'n sync with very little setup. For now, it relies on Pusher.

## Installation

First, Add `gem 'jibe'` to your application's Gemfile and `bundle`.

Then, [Set up Pusher.](https://github.com/pusher/pusher-gem) You'll also need to throw your pusher key into a meta tag named `pusher-key`.

Add `//= require jibe` to your `application.js` file.

Add `jibe` to your model.

```
class Comment < ActiveRecord::Base
  jibe
end
```

Replace a collection render call:

```
<table>
  <%= render @comments %>
</table>
```

with:

```
<table>
  <%= jibe @comments %>
</table>
```

Now, all those `@comments` will stay in sync. At this point, its probably worth adding `remote: true` to your forms.

## Options

```
<%=
  jibe @comments, 
    strategy: "prepend", # by default, new tasks are appended
    scope: "completed", # useful in conjunction with JS callbacks
    restrict_to: [@folder, current_user] # limit access
%>
```

You can hijack the `beforeCreate`, `afterCreate`, `beforeUpdate`, `afterUpdate`, `beforeDestroy`, `afterDestroy` events. This is helpful for transitions.

```
Jibe.events["comments"] =
	beforeCreate: (partial, data, scope) ->
    # partial = the DOM node
    # data = the model's attributes (override with jibe_data method in your model)
    # scope = an optional scope based on the jibe tag in your view
    
```

## Contributing

1. Fork it ( https://github.com/dallasread/jibe/fork )
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 a new Pull Request

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
jibe-0.0.3 README.md