Sha256: dadb6f26ecda4107f0fade0329b3fd3746f4876ecaf448f4fcfe1e20e6317107

Contents?: true

Size: 1011 Bytes

Versions: 3

Compression:

Stored size: 1011 Bytes

Contents

module ActionController
  module Macros
    module InPlaceEditing #:nodoc:
      def self.included(base) #:nodoc:
        base.extend(ClassMethods)
      end

      # DEPRECATION WARNING: This method will become a separate plugin when Rails 2.0 ships.
      #
      # 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.
      module ClassMethods
        def in_place_edit_for(object, attribute, options = {})
          define_method("set_#{object}_#{attribute}") do
            @item = object.to_s.camelize.constantize.find(params[:id])
            @item.update_attribute(attribute, params[:value])
            render :text => @item.send(attribute).to_s
          end
        end
      end
    end
  end
end

Version data entries

3 entries across 3 versions & 2 rubygems

Version Path
actionpack-1.13.6 lib/action_controller/macros/in_place_editing.rb
actionpack-1.13.5 lib/action_controller/macros/in_place_editing.rb
radiant-0.6.4 vendor/rails/actionpack/lib/action_controller/macros/in_place_editing.rb