Sha256: b89376655a6db81428ab8a5b53ba7eb0e179513fecfa608a747881301b4b267c

Contents?: true

Size: 926 Bytes

Versions: 8

Compression:

Stored size: 926 Bytes

Contents

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

      # 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)
          end
        end
      end
    end
  end
end

Version data entries

8 entries across 8 versions & 1 rubygems

Version Path
actionpack-1.12.0 lib/action_controller/macros/in_place_editing.rb
actionpack-1.11.2 lib/action_controller/macros/in_place_editing.rb
actionpack-1.12.1 lib/action_controller/macros/in_place_editing.rb
actionpack-1.11.1 lib/action_controller/macros/in_place_editing.rb
actionpack-1.12.4 lib/action_controller/macros/in_place_editing.rb
actionpack-1.12.3 lib/action_controller/macros/in_place_editing.rb
actionpack-1.12.2 lib/action_controller/macros/in_place_editing.rb
actionpack-1.12.5 lib/action_controller/macros/in_place_editing.rb