Sha256: 5a48faa6a3aa7a36adb68825c138c69f8b0505e4655da02ae1e9b4b391f52c31

Contents?: true

Size: 1.59 KB

Versions: 1

Compression:

Stored size: 1.59 KB

Contents

module C80NewsTz
  module CompaniesHelper

    # рендер списка компаний
    def render_companies_list(page = 1, per_page = 8)

      # NB:: передаём в партиал два списка:
      # NB::  - один: непосредственно для ренедра
      # NB::  - другой: вспомогательный, для передачи в виде аргумента в will_paginate

      companies = Company.paginate(page: page, per_page: per_page)
      companies_list = arrange_companies_list(companies)

      render :partial => 'c80_news_tz/companies/shared/companies_list',
             :locals => {
                 companies_for_render: companies_list,
                 companies: companies
             }
    end

    private

    # подготовить данные для рендера списка компаний во view
    def arrange_companies_list(companies)
      result = []
      companies.each do |company|
        wh = company.logo.thumb_preview_list_wh
        result << {
            title: company.title,
            activity_type: company.activity_type,
            href: apph_url_for_company(company.slug),
            pubs_count: company.facts.count,
            desc_short: company.desc_short,
            logo: {
                :alt_image => company.title,
                :image => company.logo.thumb_preview_list,
                :ww => wh[0],
                :hh => wh[1],
                :a_href => apph_url_for_company(company.slug),
                :a_class => 'preview_image'
            }
        }

      end
      result
    end

  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
c80_news_tz-0.1.1.26 app/helpers/c80_news_tz/companies_helper.rb