acts_as_confirmable rails plugin
11 Jun 2008acts_as_confirmable
is a Ruby on Rails plugin that is useful when you want to know who ticked a check box and when they did so. It can be found on GitHub.
This plugin treats a datetime attribute and an integer attribute as a boolean. This boolean can then be used as normal attribute in a check box (or in any part of the program) and when it is checked, the datetime records the moment and the integer records the id of the current user.
It is assumed that there is a Users table and that the current user can be found at User.current_user. If the current user cannot be accessed then 1 is used as the id.
Installation
Usage
- On models where you want to be able to confirm X add a
X_confirmed_at
datetime andX_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
create users table and items table with 3 confirmable fields
add the plugin to the model
add 3 check boxes in items/new.html.erb and items/edit.html.erb
show the confirmation info in items/list.html.erb
example of assigning a user to current_user
Available fields
If a model has the attributes fields started_confirmed_at
and started_confirmed_by
, then the plugin provides:
started?
true if it has been confirmed by someone on a specific datestarted
same as above but is normally used by a check box tagstarted=
the assignment method that is used by the check box when postingstarted_confirmer
the user that confirmed itstarted_at
when it was confirmed