This repository is private.
All pages are served over SSL and all pushing and pulling is done over SSH.
No one may fork, clone, or view it unless they are added as a member.
Every repository with this icon (
) is private.
Every repository with this icon (
This repository is public.
Anyone may fork, clone, or view it.
Every repository with this icon (
) is public.
Every repository with this icon (
commit 84ad89725a2d6b725a6f8e433372094cfe68ce8f
tree 7d18ea93d1d621d3ce77ff2e3fc0e516cb158691
parent fa90a27f83b8df8feed07ca4b5b9eed907e0d3b0
tree 7d18ea93d1d621d3ce77ff2e3fc0e516cb158691
parent fa90a27f83b8df8feed07ca4b5b9eed907e0d3b0
shadow /
| name | age | message | |
|---|---|---|---|
| |
MIT-LICENSE | Fri May 02 15:52:03 -0700 2008 | [TheBreeze] |
| |
README.markdown | Fri May 30 12:25:11 -0700 2008 | [TheBreeze] |
| |
Rakefile | Fri May 02 15:52:03 -0700 2008 | [TheBreeze] |
| |
TODO | Fri May 02 16:18:17 -0700 2008 | [TheBreeze] |
| |
init.rb | Fri May 02 15:52:03 -0700 2008 | [TheBreeze] |
| |
lib/ | Mon Jul 21 15:30:59 -0700 2008 | [TheBreeze] |
| |
test/ | Fri May 02 15:52:03 -0700 2008 | [TheBreeze] |
README.markdown
Shadow
Provides a history of attribute and association updates for models. This coincides with a versioning system (such as actsasversioned). When used in tandem, you get both a history of changes and a history of what changed.
Installation
If you are running Edge Rails, installation is straightforward:
$ ./script/plugin install git://github.com/TheBreeze/shadow.git
Otherwise, the process is a bit more involved, see below:
$ cd /path/to/your/rails/app
$ git clone --depth 1 git://github.com/TheBreeze/shadow.git "./vendor/plugins/shadow/"; rm -rf ./vendor/plugins/shadow/.git
Example
HTML parse error:
<pre><code>
# After creating your migrations (see TODO)
# In your model
class Vacation < ActiveRecord::Base
has_many :photos
# By default, shadows all :attributes and :associations. Here we're attaching a user, so we know who added a photo.
shadow :associations => :photos, :attach => :user
end
</code></pre>HTML parse error:
<pre><code>
# In your controller (here we assume nested under VacationController)
class PhotosController < ApplicationController
def create
@vacation = Vacation.find params[:vacation_id]
# This is where you attach the :user to the photo. If Photo doesn't have a user attribute or association, shadow
# will attach an attr_accessor to it and store it with the AssociationShadow record.
@photo = Photo.new params[:photo].merge(:user => current_user)
# You must either use the #association<<, #association.push, or #association.create for the shadow to be created.
if @vacation.photos << @photo
# success!
end
end
end
</code></pre>
# In your view (displaying the updates in the show action of VacationController)
<h1>Vacation Updates</h1>
<% @vacation.association_updates.each do |update| -%>
<p><%= update.user.name %> <%= update.action %> <%= update.record.thumbnail %> to <%= update.association %></p>
<% end -%>
# Example result from view:
<h1>Vacation Updates</h1>
<p>Jordan added [photo thumbnail] to photos</p>
Copyright (c) 2008 Jordan Fowler, released under the MIT license, and originally developed for Cinema Treasures, LLC (http://www.cinematreasures.org/).





