I have made myself a small activity model like this =>
# == Schema Information
# Schema version: 20110519174324
#
# Table name: activities
#
# id :integer not null, primary key
# account_id :integer
# action :string(255)
# item_id :integer
# item_type :string(255)
# created_at :datetime
# updated_at :datetime
belongs_to :account
belongs_to :item, :polymorphic => true
from this i can get a nice timeline/actions/userfeed or what we want
to call it from =>
def self.get_items(account)
item_list = []
items = where(:account_id => account.id).order("created_at
DESC").limit(30)
items.each do |i|
item_list << i.item_type.constantize.find(i.item_id)
end
item_list
end
it works like a charm for objects not refering to others - like if a
user uploads a new image i can
get the image nice and tidy. But for comments => then i want to get
the original post info, can i get
that in get_items directly ? Someone got tips for me ?
/Niklas
--
You received this message because you are subscribed to the Google Groups "Ruby
on Rails: Talk" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to
[email protected].
For more options, visit this group at
http://groups.google.com/group/rubyonrails-talk?hl=en.