Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
dd0d7a3
commit be23825
Showing
1 changed file
with
90 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,90 @@ | ||
Yaripe (Yet Another RESTful in_place_edit) | ||
=========================================== | ||
|
||
Yaripe is an Ajax Inplace Editor solution, that uses the RESTful controllers, and JQuery, to make a better solution | ||
for in place edit with rails... | ||
|
||
This Plugin is based in REST in Place (http://github.com/janv/rest_in_place) and in better-edit-in-place (http://github.com/nakajima/better-edit-in-place/tree/master) , | ||
Thanks for the ideas and for the code, guys! | ||
|
||
It uses the HTTP method put, parse the response in JSON format, and make some magic :-) | ||
|
||
How to Install | ||
---------------- | ||
|
||
script/plugin install git://github.com/tchandy/yaripe.git | ||
|
||
Dependencies | ||
------------- | ||
|
||
JRails (http://github.com/aaronchi/jrails/tree/master) | ||
|
||
|
||
Examples | ||
---------- | ||
|
||
Your routes.rb: | ||
|
||
map.resources :users | ||
|
||
Just make the Update action of your controller respond json: | ||
|
||
format.json { render :json => @user } | ||
|
||
Example: | ||
|
||
def update | ||
@user = User.find(params[:id]) | ||
|
||
respond_to do |format| | ||
if @user.update_attributes(params[:user]) | ||
flash[:notice] = 'User was successfully updated.' | ||
format.html { redirect_to(@user) } | ||
format.json { render :json => @user } | ||
else | ||
format.html { render :action => "edit" } | ||
end | ||
end | ||
end | ||
|
||
|
||
Add the Javascript to your views: | ||
|
||
<%= javascript_include_tag :defaults %> | ||
<%= javascript_include_tag "jquery.yaripe.js" %> | ||
|
||
In your views: | ||
|
||
<%= edit_in_place @user, :first_name %> | ||
|
||
For date fields: | ||
|
||
<%= edit_in_place @user, :date_of_birth, {:field_type => "date"} %> | ||
|
||
For select fields: | ||
|
||
<%= edit_in_place @user, :relationship, {:field_type => "select", :select_options => ["Single", "Married"] } %> | ||
|
||
Setting the url manualy: | ||
|
||
<%= edit_in_place @user, :first_name, { :url => admin_user_path(@user) } %> | ||
|
||
For nested routes: | ||
|
||
<%= edit_in_place [@user, @post], :title %> | ||
|
||
TODO | ||
------ | ||
|
||
- Write somes Specs | ||
- Javascript Refactor | ||
- Better documentation | ||
|
||
|
||
Contribute | ||
------------ | ||
|
||
Please, if you have any questions, contributions or suggestions, please, drop me a message or send a pull request.. | ||
|
||
|
||
Copyright (c) 2008 [Thiago Pradi], released under the MIT license |