Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- t.integer "user_id"
- t.text "message"
- t.datetime "created_at"
- t.datetime "updated_at"
- t.integer "pitch_id"
- t.integer "activity"
- t.integer "parent_id"
- t.integer "activitable_id"
- t.string "activitable_type"
- t.integer "status", default: 1
- belongs_to :user
- belongs_to :activitable,
- polymorphic: true
- has_many :comments,
- -> { approved.order(created_at: :desc) },
- class_name: 'Activity',
- foreign_key: 'parent_id'
- def message
- return self[:message] || "" if activity==0 || (activitable.nil? && activity!=1) || (activity==5 && !activitable.is_a?(Crowdfunding))
- begin
- case activity
- when 1
- "Joined on #{l user.created_at, format: :dayMonYear}."
- when 2
- "Has connected his account with #{link_to activitable.provider.humanize.titlecase, activitable.profile_link || (activitable.get_profile_link && activitable.profile_link) || "#", target: '_blank'}"
- when 3
- "Is now following #{link_to activitable.title, activitable, target: '_blank'}"
- when 4
- "Is now following #{link_to activitable.profile.selected_name, activitable.profile, target: '_blank'}"
- when 5
- "#{activitable.pitch_type==0 ? 'Backed' : 'Invested in'} #{activitable.pitch.title}."
- when 6
- "Published new investment opporunity #{activitable.pitch.title}"
- end
- rescue
- nil
- end
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement