Sha256: 692102ae3b00ab11525fb0bae02a05af0a4bce412367293b843fe83d8de833bd

Contents?: true

Size: 1.03 KB

Versions: 1

Compression:

Stored size: 1.03 KB

Contents

= track_changes

TrackChanges is a Rails plugin to facilitate tracking
changes made to an ActiveRecord model in your
Controller#update actions. By default, the block is
only called if the changes hash is not empty.

A TrackChanges::Filter is instantiated on each run of the <tt>before_filter</tt>
so it should be thread-safe.

Consult the generated rdoc for more information.

== Example

  class PostController < ApplicationController
    include TrackChanges

    before_filter :get_post, :except => [:index, :new]

    track_changes_to :post do |r|
      # r.changes => Model#changes made during update action
      RAILS_DEFAULT_LOGGER.debug(r.changes.inspect)
    end


    def update
      if @post.update_attributes(params[:post])
        flash[:notice] = "Success."
      else
        render :action => "edit"
      end
    end

    # Normal controller actions
    # ...

    protected

    def get_post
      @post = Post.find(params[:id])
    end
  end


== COPYRIGHT

Copyright (c) 2008 Matt Haley. See link:files/LICENSE.html for details.

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
smajn-track_changes-0.3.0 README