Yaripe - Yet Another RESTful in place edit
JavaScript Ruby
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Failed to load latest commit information.
javascripts
lib
README.mkdn
init.rb
install.rb
uninstall.rb

README.mkdn

Yaripe (Yet Another RESTful in_place_edit)

Yaripe is a Rails plugin for Inplace Edit solution, that uses the RESTful controllers, and JQuery, to make a complete solution of in place edit...

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:

class UsersController < ApplicationController
  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
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) 2009 [Thiago Pradi], released under the MIT license