put some dependent destroys on models for better sqlite compatability
This commit is contained in:
parent
c12103aed9
commit
890dc7efd5
6 changed files with 12 additions and 10 deletions
1
Gemfile
1
Gemfile
|
|
@ -2,6 +2,7 @@ source 'http://rubygems.org'
|
|||
|
||||
gem 'mysql2', '0.2.6'
|
||||
#gem 'pg'
|
||||
#gem 'sqlite3'
|
||||
gem 'rails', '3.0.3'
|
||||
gem 'foreigner', '0.9.1'
|
||||
|
||||
|
|
|
|||
|
|
@ -10,7 +10,7 @@ class AspectMembership < ActiveRecord::Base
|
|||
has_one :person, :through => :contact
|
||||
|
||||
before_destroy do
|
||||
if self.contact.aspects.size == 1
|
||||
if self.contact && self.contact.aspects.size == 1
|
||||
self.user.disconnect(self.contact)
|
||||
end
|
||||
true
|
||||
|
|
|
|||
|
|
@ -7,7 +7,7 @@ class Notification < ActiveRecord::Base
|
|||
include Diaspora::Socketable
|
||||
|
||||
belongs_to :recipient, :class_name => 'User'
|
||||
has_many :notification_actors
|
||||
has_many :notification_actors, :dependent => :destroy
|
||||
has_many :actors, :class_name => 'Person', :through => :notification_actors, :source => :person
|
||||
belongs_to :target, :polymorphic => true
|
||||
|
||||
|
|
|
|||
|
|
@ -17,7 +17,7 @@ class Person < ActiveRecord::Base
|
|||
xml_attr :profile, :as => Profile
|
||||
xml_attr :exported_key
|
||||
|
||||
has_one :profile
|
||||
has_one :profile, :dependent => :destroy
|
||||
delegate :last_name, :to => :profile
|
||||
|
||||
before_validation :downcase_diaspora_handle
|
||||
|
|
@ -25,8 +25,9 @@ class Person < ActiveRecord::Base
|
|||
diaspora_handle.downcase! unless diaspora_handle.blank?
|
||||
end
|
||||
|
||||
has_many :contacts #Other people's contacts for this person
|
||||
has_many :posts, :foreign_key => :author_id #his own posts
|
||||
has_many :contacts, :dependent => :destroy #Other people's contacts for this person
|
||||
has_many :posts, :foreign_key => :author_id, :dependent => :destroy #his own posts
|
||||
has_many :comments, :foreign_key => :author_id, :dependent => :destroy #his own comments
|
||||
|
||||
belongs_to :owner, :class_name => 'User'
|
||||
|
||||
|
|
|
|||
|
|
@ -13,7 +13,7 @@ class Post < ActiveRecord::Base
|
|||
xml_attr :public
|
||||
xml_attr :created_at
|
||||
|
||||
has_many :comments, :order => 'created_at ASC'
|
||||
has_many :comments, :order => 'created_at ASC', :dependent => :destroy
|
||||
has_many :likes, :conditions => {:positive => true}, :dependent => :delete_all
|
||||
has_many :dislikes, :conditions => {:positive => false}, :class_name => 'Like', :dependent => :delete_all
|
||||
|
||||
|
|
|
|||
|
|
@ -31,14 +31,14 @@ class User < ActiveRecord::Base
|
|||
has_one :person, :foreign_key => :owner_id
|
||||
delegate :public_key, :posts, :owns?, :diaspora_handle, :name, :public_url, :profile, :first_name, :last_name, :to => :person
|
||||
|
||||
has_many :invitations_from_me, :class_name => 'Invitation', :foreign_key => :sender_id
|
||||
has_many :invitations_to_me, :class_name => 'Invitation', :foreign_key => :recipient_id
|
||||
has_many :invitations_from_me, :class_name => 'Invitation', :foreign_key => :sender_id, :dependent => :destroy
|
||||
has_many :invitations_to_me, :class_name => 'Invitation', :foreign_key => :recipient_id, :dependent => :destroy
|
||||
has_many :aspects
|
||||
has_many :aspect_memberships, :through => :aspects
|
||||
has_many :contacts
|
||||
has_many :contact_people, :through => :contacts, :source => :person
|
||||
has_many :services
|
||||
has_many :user_preferences
|
||||
has_many :services, :dependent => :destroy
|
||||
has_many :user_preferences, :dependent => :destroy
|
||||
|
||||
before_save do
|
||||
person.save if person && person.changed?
|
||||
|
|
|
|||
Loading…
Reference in a new issue