README.md in bootstrap-editable-rails-0.0.1 vs README.md in bootstrap-editable-rails-0.0.2
- old
+ new
@@ -1,10 +1,10 @@
# Bootstrap Editable Rails
In-place editing with Twitter Bootstrap for Rails
-This gem is based on X-editable (v1.1.1) which is the new version of Bootstrap Editable.
+This gem is based on X-editable (v1.3.0) which is the new version of Bootstrap Editable.
https://github.com/vitalets/x-editable
## Demo & Documents
@@ -20,10 +20,12 @@
$ bundle
## Usage
+### JavaScript & Stylesheet
+
Write the top of `app/assets/javascripts/application.js` like this:
```javascript
//= require jquery
//= require jquery_ujs
@@ -31,10 +33,57 @@
//= require bootstrap-editable
//= require bootstrap-editable-rails
//= require_tree .
```
+(You can choose `bootstrap-editable-inline`)
+
and need to load `bootstrap-editable.css` at the place where you like.
+
+### HTML
+
+Follow the documents above.
+
+Additional required attribute(option) is `resource`.
+
+```html
+<a href="#" id="username" data-type="text" data-resource="post" data-name="username" data-url="/posts/1" data-original-title="Enter username">superuser</a>
+```
+
+then, sends `PUT /posts/1` request with the body:
+
+```
+post[username]=superuser
+```
+
+### Controller
+
+PostsController receives the parameters
+
+```
+{ "id" => "1", "post" => { "username" => "superuser" } }
+```
+
+and must respond with 2xx (means _success_) status code if successful.
+
+For example, scaffold goes well because default dataType is json.
+
+```ruby
+def update
+ @post = Post.find(params[:id])
+
+ respond_to do |format|
+ if @post.update_attributes(params[:post])
+ format.html { redirect_to @post, notice: 'Post was successfully updated.' }
+ format.json { head :no_content } # 204 No Content
+ else
+ format.html { render action: "edit" }
+ format.json { render json: @post.errors, status: :unprocessable_entity }
+ end
+ end
+end
+```
+
## Contributing
1. Fork it
2. Create your feature branch (`git checkout -b my-new-feature`)