Example:
# Controller
class BlogController < ApplicationController
in_place_edit_for :post, :title
end
# View
<%= in_place_editor_field :post, 'title' %>
For help on defining an in place editor in the browser, see ActionView::Helpers::JavaScriptHelper.
Methods
Public Instance methods
[ show source ]
# File vendor/rails/actionpack/lib/action_controller/macros/in_place_editing.rb, line 22
22: def in_place_edit_for(object, attribute, options = {})
23: define_method("set_#{object}_#{attribute}") do
24: @item = object.to_s.camelize.constantize.find(params[:id])
25: @item.update_attribute(attribute, params[:value])
26: render :text => @item.send(attribute)
27: end
28: end