public
Description: The open source social networking platform in Ruby on Rails from the author of RailsSpace
Homepage: http://insoshi.com
Clone URL: git://github.com/insoshi/insoshi.git
Comments, with working WallComment model
Michael Hartl (author)
Mon Feb 25 22:57:00 -0800 2008
commit  d1a6476dee3950693ee31c9d78c714162ae13c2b
tree    38c631832258d14ebf23d3b0948fe24378b93093
parent  b8324cc82bfea99134f9afed28b99df07fe1f4d7
...
1
2
3
4
5
 
 
6
7
8
...
19
20
21
22
 
 
 
 
 
 
 
23
 
 
 
24
25
26
...
28
29
30
31
32
33
34
35
36
37
38
39
40
...
1
2
 
 
 
3
4
5
6
7
...
18
19
20
 
21
22
23
24
25
26
27
28
29
30
31
32
33
34
...
36
37
38
 
 
 
 
 
 
 
39
40
41
0
@@ -1,8 +1,7 @@
0
 class Person < ActiveRecord::Base
0
 
0
- if !test? or (test? and FERRET_IN_TESTS)
0
- acts_as_ferret :fields => [ :name, :description ]
0
- end
0
+
0
+ acts_as_ferret :fields => [ :name, :description ] if ferret?
0
 
0
   attr_accessor :password, :sorted_photos
0
   attr_accessible :email, :password, :password_confirmation, :name,
0
@@ -19,8 +18,17 @@ class Person < ActiveRecord::Base
0
   MESSAGES_PER_PAGE = 5
0
   NUM_RECENT_MESSAGES = 4
0
   NUM_RECENTLY_VIEWED = 4
0
-
0
+
0
+ has_one :blog
0
+ has_many :comments, :class_name => "WallComment"
0
+ has_many :connections
0
+ # TODO: refactor the statuses to use numerical codes/model constants.
0
+ has_many :contacts, :through => :connections,
0
+ :conditions => "status = 'accepted'"
0
   has_many :photos, :dependent => :destroy, :order => 'created_at'
0
+ has_many :requested_contacts, :through => :connections,
0
+ :source => :contact,
0
+ :conditions => "status = 'requested'"
0
   with_options :class_name => "Message", :dependent => :destroy,
0
                :order => 'created_at DESC' do |person|
0
     person.has_many :_sent_messages, :foreign_key => "sender_id",
0
@@ -28,13 +36,6 @@ class Person < ActiveRecord::Base
0
     person.has_many :_received_messages, :foreign_key => "recipient_id",
0
                     :conditions => "recipient_deleted_at IS NULL"
0
   end
0
- has_many :connections
0
- has_many :contacts, :through => :connections,
0
- :conditions => "status = 'accepted'"
0
- has_many :requested_contacts, :through => :connections,
0
- :source => :contact,
0
- :conditions => "status = 'requested'"
0
- has_one :blog
0
   
0
   validates_presence_of :email
0
   validates_presence_of :password, :if => :password_required?
...
6
7
8
9
10
 
 
 
 
 
 
 
...
6
7
8
 
9
10
11
12
13
14
15
16
0
@@ -6,4 +6,10 @@ MAX_TEXT_LENGTH = 1000
0
 
0
 # Ferret adds a significant overhead to tests, so disable it by default.
0
 # Set this to true to run the tests with Ferret enabled.
0
-FERRET_IN_TESTS = false
0
\ No newline at end of file
0
+FERRET_IN_TESTS = false
0
+
0
+# True if Ferret should do its thing.
0
+# Ferret should not run unless FERRET_IN_TESTS is true.
0
+def ferret?
0
+ !test? or (test? and FERRET_IN_TESTS)
0
+end
...
1
 
 
2
3
4
...
1
2
3
4
5
6
0
@@ -1,4 +1,6 @@
0
 ActionController::Routing::Routes.draw do |map|
0
+ map.resources :comments
0
+
0
   map.resources :blogs do |blog|
0
     blog.resources :posts
0
   end
...
38
39
40
 
 
 
 
41
42
43
...
38
39
40
41
42
43
44
45
46
47
0
@@ -38,6 +38,10 @@ describe Person do
0
       person = create_person(:save => true)
0
       person.blog.should_not be_nil
0
     end
0
+
0
+ it "should have many wall comments" do
0
+ create_person.comments.should be_a_kind_of(Array)
0
+ end
0
   end
0
   
0
   describe "photo methods" do

Comments

    No one has commented yet.