molten-trunk/molten5_withgrid/lib/acts_as_viewable.rb
# Returns the most viewed records.
Returns the most viewed records.
Returns the most viewed records .
def find_popular(limit = AppConstants::MOST_POPULAR_LIMIT)
            return [] unless self.new.respond_to?(:views)
            conditions = if self.to_s == 'Sfsolution'
                            "status = '#{Sfsolution::STATUSES[:published]}'"
                         else
                           ""
                         end
            records = self.new.build_settings.class.find(:all, :order => "views DESC", :limit => limit).map do |setting| 
              setting.send(self.new.class.to_s.underscore)
            end
            records.reject { |record| record.is_a?(Sfsolution) and !record.published? }.compact
          end
def find_popular ( limit = AppConstants :: MOST_POPULAR_LIMIT ) return [ ] unless self . new . respond_to? ( :views ) conditions = if self . to_s == 'Sfsolution' "status = '#{Sfsolution::STATUSES[:published]}'" else "" end records = self . new . build_settings . class . find ( :all , :order => "views DESC" , :limit => limit ) . map do | setting | setting . send ( self . new . class . to_s . underscore ) end records . reject { | record | record . is_a? ( Sfsolution ) and ! record . published? } . compact end
Returns the most viewed records.
Returns the most viewed records .
limit