Acts As Confirmation plugin

Plugin details

acts_as_confirmable is useful when you want to know who ticked a check box and when they did so.

Websitehttp://www.kumo.it/articles/2008/06/11/acts_as_confirmable-plugin/ Repositorygit://github.com/kumo/acts_as_confirmable.git Author Rob Clarke Tags HTML LicenseMIT

Documentation

Install the plugin:
ruby script/plugin install git://github.com/kumo/acts_as_confirmable.git

Installation
============

$ cd vendor/plugins
$ git checkout git://github.com/kumo/acts_as_confirmable/tree



Usage
=====

- On models where you want to be able to confirm X add a X_confirmed_at datetime and X_confirmed_by integer.
- In the model put acts_as_confirmed :X
- In the views add check boxes (check_box :X)


Example
=======

- create a new rails app

$ rails confirm
$ cd confirm


- create the users table

$ script/generate scaffold user name:string


- create an items table with 3 confirmable fields

$ script/generate scaffold item name:string started_confirmed_by:integer started_confirmed_at:datetime 
finished_confirmed_by:integer finished_confirmed_at:datetime ready_confirmed_by:integer ready_confirmed_at:datetime


- add the plugin to the model

class Item < ActiveRecord::Base
  acts_as_confirmable :started, :finished, :ready
end


- add 3 check boxes in items/new.html.erb and items/edit.html.erb

< p>
  <%= f.label :started %>< br />
  <%= f.check_box :started %>
< /p>
< p>
  <%= f.label :finished %>< br />
  <%= f.check_box :finished %>
< /p>
< p>
  <%= f.label :ready %>< br />
  <%= f.check_box :ready %>
< /p>


- show the confirmation info in items/list.html.erb

< td><%=h item.started? %> <%= item.started_confirmer.name if item.started? %>< /td>


- example of assigning a user to current_user

class User < ActiveRecord::Base
  cattr_accessor :current_user
end

class ItemsController < ApplicationController
  before_filter :load_user

  protected

  def load_user
    User.current_user = User.find(:first)
  end
end



Available fields
================

If a model has the attributes started_confirmed_at and started_confirmed_by, then the plugin provides:

* started? -- true if it has been confirmed by someone on a specific date
* started -- same as above but is normally used by a check box tag
* started= -- the assignment method that is used by the check box when posting
* started_confirmer -- the user that confirmed it
* started_at -- when it was confirmed

Further Documentation

There is currently no advanced documentation for this plugin.

New documentation

Edit plugin | (0 older versions) | Last edited by: hardway, 4 months ago