• R/O
  • SSH
  • HTTPS

minisns: 提交


Commit MetaInfo

修订版14 (tree)
时间2009-02-11 12:29:46
作者rainyrook

Log Message

(empty log message)

更改概述

差异

--- minisns/app/models/user.rb (revision 13)
+++ minisns/app/models/user.rb (revision 14)
@@ -2,14 +2,25 @@
22 class User < ActiveRecord::Base
33 # Virtual attribute for the unencrypted password
44 before_create :make_activation_code
5- has_one :user_info, :dependent => :destroy
6-# has_many :blog_entries, :dependent => :destroy
7- has_many :account_blog_entries, :dependent => :destroy
8- has_many :blog_entries, :dependent => :destroy, :through => :account_blog_entries
9- has_many :pictures, :dependent => :destroy
10- has_many :account_associations , :dependent => :destroy
11- has_many :child_users, :class_name => "User", :through => :account_associations
12-# belongs_to :parent_users, :class_name => "User", :through => :account_associations
5+ has_one :user_info, :dependent => :destroy
6+ has_many :account_blog_entries, :dependent => :destroy
7+ has_many :blog_entries, :dependent => :destroy, :through => :account_blog_entries
8+ has_many :pictures, :dependent => :destroy
9+
10+ has_many :parent_account_associations,
11+ :foreign_key => 'user_id',
12+ :class_name=>'AccountAssociation'
13+ has_many :child_account_associations,
14+ :foreign_key => 'associated_user_id',
15+ :class_name=>'AccountAssociation'
16+
17+ has_many :parent_accounts,
18+ :through => :parent_account_associations ,
19+ :source => :child_account
20+ has_many :child_accounts,
21+ :through => :child_account_associations,
22+ :source => :parent_account
23+
1324 has_many :account_one_line_comment_associations, :dependent => :destroy
1425 has_many :one_line_comments, :dependent => :destroy, :through => :account_one_line_comment
1526
--- minisns/app/models/account_association.rb (revision 13)
+++ minisns/app/models/account_association.rb (revision 14)
@@ -1,4 +1,4 @@
11 class AccountAssociation < ActiveRecord::Base
2- belongs_to :user
3- belongs_to :user_info
2+ belongs_to :parent_account, :foreign_key => 'associated_user_id', :class_name=>'User'
3+ belongs_to :child_account, :foreign_key => 'user_id',:class_name=>'User'
44 end
--- minisns/app/models/user_info.rb (revision 13)
+++ minisns/app/models/user_info.rb (revision 14)
@@ -7,4 +7,15 @@
77 validates_length_of :zip_code, :within => 7..7
88 validates_length_of :address1, :within => 1..254
99 validates_length_of :telephone, :within => 1..40
10+
11+ def get_profile_picture
12+ a_users_picture_profile = Picture.find(:first, :conditions => ["user_id = ? and profile_picture_flag = true", id])
13+ alt_string="#{self.user_info.last_name} #{self.first_name}"
14+ unless a_users_picture_profile.nil?
15+ image_string = image_tag url_for_image_column(a_users_picture_profile, "image_name", :thumb)
16+ else
17+ image_string = "<img src='/images/noimage_member76.gif' WIDTH='50' HEIGHT='50' alt='#{alt_string}'>"
18+ end
19+ image_string
20+ end
1021 end
--- minisns/app/controllers/mypage_controller.rb (revision 13)
+++ minisns/app/controllers/mypage_controller.rb (revision 14)
@@ -7,7 +7,7 @@
77
88 def view
99 account_associations = AccountAssociation.find(:all, :conditions => ["user_id = ? ",self.current_user.id])
10-
10+ p self.current_user.child_accounts.size
1111 sql_str = "";
1212 account_associations.each do |account_association|
1313 sql_str = sql_str + " , " unless sql_str == ""
Show on old repository browser