<commit_before># Abracadabra

A lightweight gem for swapping out text with a fully-compliant Rails form in one click.

Much of the concepts and html mark-up were taken from the awesome [x-editable](http://vitalets.github.io/x-editable/) plugin and the Rails version of this, [x-editable-rails](https://github.com/werein/x-editable-rails). However, this was written from the ground up and uses fully Rails-compliant forms without hacking into x-editable's core files, or overriding them.

## Installation

Add this line to your application's Gemfile:

    gem 'abracadabra'

And then execute:

    $ bundle

Or install it yourself as:

    $ gem install abracadabra

## Usage

In your `application.css`, AFTER Bootstrap (currently only supports Bootstrap), include the css file:

```css
 *= require abracadabra
```

In your `application.js`, AFTER Jquery (required), include the javascript file:

```js
 //= require abracadabra
```

## Helpers

The bread and butter of abracadabra is its helper, `click_to_edit`. Its pretty much as readable as it gets:

```ruby
<%= click_to_edit @user, path: user_path(@user), attribute: :name %>
```

When a user clicks the link generated by this helper, a form with a text field input will replace the link. It's fully Rails compliant, and looks identical to a `form_for` with `remote: true`. Currently, it only responds to javascript, but other datatypes will be supported soon. Here's what it looks like:

[Video of abracadabra in action!](http://recordit.co/cpwdWIyEN4)

The first parameter is the object to be edited, and the only other required parameters are `path` and `attribute`. `path` specifies where the form will be submitted, and `attribute` specifies the column being updated.

It accepts the following optional hash keys (more will be added soon):

```ruby
class: "my-class"
# A class to be added to the text input of the form.

value: "blah"
# An alternate value, other than what object.attribute would return.

method: "patch"
# HTTP REST method to use. Use anything but "get".
```

## Future & Contributing

I would love anyone to add date pickers and other alternate field types to this. It would be nice to respond to more than just javascript as well (very simple to implement). Any other ideas, feel free to contribute!

1. Fork it ( http://github.com/<my-github-username>/abracadabra/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 new Pull Request<commit_msg>Fixed README<commit_after># Abracadabra

A lightweight gem for swapping out text with a fully-compliant Rails form in one click.

Much of the concepts and html mark-up were taken from the awesome [x-editable](http://vitalets.github.io/x-editable/) plugin and the Rails version of this, [x-editable-rails](https://github.com/werein/x-editable-rails). However, this was written from the ground up and uses fully Rails-compliant forms without hacking into x-editable's core files, or overriding them.

## Installation

Add this line to your application's Gemfile:

    gem 'abracadabra'

And then execute:

    $ bundle

Or install it yourself as:

    $ gem install abracadabra

## Usage

In your `application.css`, AFTER Bootstrap (currently only supports Bootstrap), include the css file:

```css
 *= require abracadabra
```

In your `application.js`, AFTER Jquery (required), include the javascript file:

```js
 //= require abracadabra
```

## Helpers

The bread and butter of abracadabra is its helper, `click_to_edit`. Its pretty much as readable as it gets:

```ruby
<%= click_to_edit @user, path: user_path(@user), attribute: :name %>
```

When a user clicks the link generated by this helper, a form with a text field input will replace the link. It's fully Rails compliant, and looks identical to a `form_for` with `remote: true`. Currently, it only responds to javascript, but other datatypes will be supported soon. Here's what it looks like:

[Video of abracadabra in action!](http://recordit.co/cpwdWIyEN4)

The first parameter is the object to be edited, and the only other required parameters are `path` and `attribute`. `path` specifies where the form will be submitted, and `attribute` specifies the column being updated.

It accepts the following optional hash keys (more will be added soon):

```ruby
class: "my-class"
# A class to be added to the text input of the form.

value: "blah"
# An alternate value, other than what object.attribute would return.

method: "patch"
# HTTP REST method to use. Use anything but "get".
```

## Future & Contributing

I would love anyone to add date pickers and other alternate field types to this. It would be nice to respond to more than just javascript as well (very simple to implement). Any other ideas, feel free to contribute!

1. Fork it ( http://github.com/TrevorHinesley/abracadabra/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 new Pull Request
{'fraction_non_alphanumeric': 0.08802336903602727, 'fraction_numerical': 0.0023369036027263874, 'mean_word_length': 4.338877338877339, 'pattern_counts': {'":': 0, '<': 6, '<?xml version=': 0, '>': 6, 'https://': 2, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '585573', 'n_tokens_mistral': 1543, 'n_tokens_neox': 1432, 'n_words': 712}