<commit_before>h1. Better Edit in Place

The default "in_place_editing" plugin for Rails is disappointing. This is my
solution.

h3. Features

* Support for nested resources
* RESTful. Just add a line to your @respond_to@ block to render as JSON.
* Easy to use outside of Rails. Just add a class name and the path as the
  @rel@ attribute to an element and you're done.
* Logic lives in the JavaScript (You may consider this a feature or a flaw. I
  consider it a feature.)

The better-edit-in-place script makes it easy to create AJAX edit-in-place
fields in a RESTful web app. Note that if your approach isn't RESTful, 
then this script won't do much for you.

To make an element editable, give it the class name @editable@. Specify 
the element's resource url as the element's @rel@ attribute, then give it
an @id@ attribute that contains the name of the record's model, as well as
the attribute to be edited. You can also add the record's id as well, so
as not to have multiple elements with the same id in the same page. All in,
an editable element's attributes look like this:

<pre>class="editable" id="list_1_name" rel="/lists/1"</pre>

When the element is clicked, it will be hidden, and an input will appear
that will allow the user to change the field. You must have an appropriate
respond_to set in your controller that renders the record as a JSON response.

A Rails example:

  respond_to do |format|
    format.html # Whatever
    format.js { render :json => @list }
  end

h3. Using it with Rails

If you're using this plugin in a Rails app, you can use the following view
helper to simplify the markup for your editable element:

  edit_in_place(@list, :name)

By default, the edit-in-place tag will be a @<span>@ element. You can override
this using the @:tag@ option:

  edit_in_place(@list, :name, :tag => :h1)

h4. Nested Resources

Better Edit in Place also works seamlessly with nested resources. Just pass
in the resources as an array. This will update an item's @name@ attribute:

  edit_in_place([@list, @item], :name)
  
The @list_item_path@ will be determined automatically. If you wish to
pass a different URL in, you can do that as well:

  edit_in_place([@list, @item], :name, :url => weird_item_path(@item))

h3. TODO

* Escape key should cancel (simple event handler)
* Maybe some more options (but not too many)

Copyright (c) 2008 <NAME><commit_msg>added note to readme about setting include_root_in_json config to false<commit_after>h1. Better Edit in Place

The default "in_place_editing" plugin for Rails is disappointing. This is my
solution.

h3. Features

* Support for nested resources
* RESTful. Just add a line to your @respond_to@ block to render as JSON.
* Easy to use outside of Rails. Just add a class name and the path as the
  @rel@ attribute to an element and you're done.
* Logic lives in the JavaScript (You may consider this a feature or a flaw. I
  consider it a feature.)

The better-edit-in-place script makes it easy to create AJAX edit-in-place
fields in a RESTful web app. Note that if your approach isn't RESTful, 
then this script won't do much for you.

To make an element editable, give it the class name @editable@. Specify 
the element's resource url as the element's @rel@ attribute, then give it
an @id@ attribute that contains the name of the record's model, as well as
the attribute to be edited. You can also add the record's id as well, so
as not to have multiple elements with the same id in the same page. All in,
an editable element's attributes look like this:

<pre>class="editable" id="list_1_name" rel="/lists/1"</pre>

When the element is clicked, it will be hidden, and an input will appear
that will allow the user to change the field. You must have an appropriate
respond_to set in your controller that renders the record as a JSON response.

A Rails example:

  respond_to do |format|
    format.html # Whatever
    format.js { render :json => @list }
  end

h3. Using it with Rails

If you're using this plugin in a Rails app, you can use the following view
helper to simplify the markup for your editable element:

  edit_in_place(@list, :name)

By default, the edit-in-place tag will be a @<span>@ element. You can override
this using the @:tag@ option:

  edit_in_place(@list, :name, :tag => :h1)

h4. Nested Resources

Better Edit in Place also works seamlessly with nested resources. Just pass
in the resources as an array. This will update an item's @name@ attribute:

  edit_in_place([@list, @item], :name)
  
The @list_item_path@ will be determined automatically. If you wish to
pass a different URL in, you can do that as well:

  edit_in_place([@list, @item], :name, :url => weird_item_path(@item))

h4. If you're using a newer version of Rails...

You might need to tell ActiveRecord not to include the root while serializing
to JSON. To do so, put this line in an initializer, or environment.rb:

  ActiveRecord::Base.include_root_in_json = false

h3. TODO

* Escape key should cancel (simple event handler)
* Maybe some more options (but not too many)

Copyright (c) 2008 <NAME>
{'fraction_non_alphanumeric': 0.06855791962174941, 'fraction_numerical': 0.004925137903861308, 'mean_word_length': 4.06686626746507, 'pattern_counts': {'":': 0, '<': 11, '<?xml version=': 0, '>': 17, 'https://': 0, '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': '2430571', 'n_tokens_mistral': 1520, 'n_tokens_neox': 1446, 'n_words': 793}