Created
January 20, 2011 01:54
-
-
Save adrianpike/787267 to your computer and use it in GitHub Desktop.
acts_as_archive examples
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class Event < ActiveRecord::Base | |
acts_as_archive :quick => true | |
belongs_to :asset | |
belongs_to :user | |
has_many :invitations, :dependent => :destroy | |
has_many :users, :through => :invitations | |
... snip ... | |
end | |
class Invitation < ActiveRecord::Base | |
acts_as_archive :quick => true | |
belongs_to :event | |
belongs_to :user | |
belongs_to :inviter, :class_name => 'User' | |
... snip ... | |
end | |
ruby-1.9.2-p0 > Event::Archive.first | |
=> #<Event::Archive id: 53, type: nil, asset_id: 2, user_id: 1, title: "Adrian Pike's Event", description: "", start: "2011-01-13 22:00:00", stop: "2011-01-14 07:00:00", reoccurrence_id: nil, exclusive: true, organizer_notes: nil, guest_notes: nil, location: "934 32nd St, Bellingham, WA 98225, USA", created_at: "2011-01-13 19:49:04", updated_at: "2011-01-13 20:32:19", schedule_type: nil, completed_at: nil, deleted_at: "2011-01-20 01:32:03"> | |
ruby-1.9.2-p0 > Invitation::Archive.first | |
=> #<Invitation::Archive id: 63, user_id: 1, event_id: 53, attendance_status: 1, created_at: "2011-01-13 19:49:05", updated_at: "2011-01-13 19:49:05", inviter_id: nil, deleted_at: "2011-01-20 01:04:22"> | |
ruby-1.9.2-p0 > Event::Archive.first.destroy | |
=> #<Event::Archive id: 53, type: nil, asset_id: 2, user_id: 1, title: "Adrian Pike's Event", description: "", start: "2011-01-13 22:00:00", stop: "2011-01-14 07:00:00", reoccurrence_id: nil, exclusive: true, organizer_notes: nil, guest_notes: nil, location: "934 32nd St, Bellingham, WA 98225, USA", created_at: "2011-01-13 19:49:04", updated_at: "2011-01-13 20:32:19", schedule_type: nil, completed_at: nil, deleted_at: "2011-01-20 01:32:03"> | |
ruby-1.9.2-p0 > Event::Archive.first | |
=> nil | |
ruby-1.9.2-p0 > Event.find(53) | |
=> #<Event id: 53, type: nil, asset_id: 2, user_id: 1, title: "Adrian Pike's Event", description: "", start: "2011-01-13 22:00:00", stop: "2011-01-14 07:00:00", reoccurrence_id: nil, exclusive: true, organizer_notes: nil, guest_notes: nil, location: "934 32nd St, Bellingham, WA 98225, USA", created_at: "2011-01-13 19:49:04", updated_at: "2011-01-13 20:32:19", schedule_type: nil, completed_at: nil> | |
ruby-1.9.2-p0 > Event.find(53).invitations | |
=> [] | |
ruby-1.9.2-p0 > Invitation::Archive.first | |
=> #<Invitation::Archive id: 63, user_id: 1, event_id: 53, attendance_status: 1, created_at: "2011-01-13 19:49:05", updated_at: "2011-01-13 19:49:05", inviter_id: nil, deleted_at: "2011-01-20 01:04:22"> | |
ruby-1.9.2-p0 > Invitation::Archive.first.destroy | |
=> #<Invitation::Archive id: 63, user_id: 1, event_id: 53, attendance_status: 1, created_at: "2011-01-13 19:49:05", updated_at: "2011-01-13 19:49:05", inviter_id: nil, deleted_at: "2011-01-20 01:04:22"> | |
ruby-1.9.2-p0 > Event.find(53).invitations | |
=> [#<Invitation id: 63, user_id: 1, event_id: 53, attendance_status: 1, created_at: "2011-01-13 19:49:05", updated_at: "2011-01-13 19:49:05", inviter_id: nil>] | |
ruby-1.9.2-p0 > |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment