molten-trunk/molten5_withgrid/app/models/sfcontact.rb
# 
# This provides #recent_class_name style methods that return a list of the
# recently viewed viewables of that class type:
# 
#   current_user.recent_sfcases  #=> [Sfcase, Sfcase, ...]
# 
This provides #recent_class_name style methods that return a list of the
recently viewed viewables of that class type.


This provides #recent_class_name style methods that return a list of the recently viewed viewables of that class type .
def method_missing(meth, *args, &block)
    if meth.to_s =~ /^recent_(\w+)$/
      recent_type = $1.singularize.camelize.constantize
      views = viewings.find(:all, :limit => AppConstants::RECENT_LIMIT, :order => "created_at DESC",
                    :conditions => "viewable_type = '#{recent_type}'").map { |viewing| viewing.viewable  }.uniq.compact
      views.reject { |v| !v.account.blank? and !account_list.include?(v.account) }
    else
      super
    end
  end
def method_missing ( meth , * args , & block ) if meth . to_s =~ / ^recent_( \w +)$ / recent_type = $1 . singularize . camelize . constantize views = viewings . find ( :all , :limit => AppConstants :: RECENT_LIMIT , :order => "created_at DESC" , :conditions => "viewable_type = '#{recent_type}'" ) . map { | viewing | viewing . viewable } . uniq . compact views . reject { | v | ! v . account . blank? and ! account_list . include? ( v . account ) } else super end end
This provides #recent_class_name style methods that return a list of the
recently viewed viewables of that class type:
This provides #recent_class_name style methods that return a list of the recently viewed viewables of that class type :
# make sure the viewings are available to this contact
meth
args
block