-
Notifications
You must be signed in to change notification settings - Fork 307
Working with the model layer
gaaady edited this page Jun 7, 2012
·
4 revisions
Here are some examples for working with Social Stream model layer
User.new do |u|
u.name="Test Name"
u.email="[email protected]"
u.password="test12345"
u.password_confirmation="test12345"
u.save!
end
p=Post.new do |p|
p.text="Sample post"
p.author_id=User.last.actor.id
p.owner_id=Actor.first.id
p.user_author_id=User.last.actor.id
p.save!
c = Comment.create! :text => "Sample comment",
:created_at => Time.now.to_i,
:updated_at => Time.now.to_i,
:author_id => User.first.actor.id,
:owner_id => p.owner_id,
:user_author_id => User.first.actor.id,
:_activity_parent_id => p.post_activity.id
l=Like.build(Actor.last, User.last, p.post_activity)
l.save
a=Actor.first
b=Actor.last
contct=a.sent_contacts.find_or_create_by_receiver_id b.id
contct.relation_ids = Array.wrap(Relation::Follow.instance.id) # A starts following B
contct.relation_ids = Array.new # A stops following B