2012-10-24 4 views
0

내가 (HAML에) 등의 RoR보기가 있습니다레일보기가 너무 많은 데이터를보고

-if @articles.blank? 
    %h3 
    Увы, нет артикулов в данной категории 

-else 
    - @constr_num.each do |cc| 
    = cc.ARL_SEARCH_NUMBER 
    %table.zebra 
    %tr 
     %th Производитель 
     %th Наименование/описание 
     %th  
     %th Цена 
     %th Кол-во на складе 
     %th Сроки поставки 
     %th 
    -if @non_original.present? 
     %br 
     - if @non_original.is_a?(Array) 
     [email protected]_original.each do |no| 
      %tr{ :class => cycle("zebra-stripe zebra-green zebra1", "zebra-stripe zebra-green zebra2")} 
      %td 
       %h4 
       =no.brand 
      %td 
       %h4 
       -if user_signed_in? 
        = no.article_nr 
       -else 
        = no.article_nr.first.concat("***").concat(no.article_nr.last)  
       =no.description 
      %td 
       = #link_to "подробнее/аналоги", "#" 
      %td 
       =no.price 
      %td 
       =no.quantity.gsub(/[^0-9]/, '').to_i 
      %td 
       =no.waittime 
      %td 
       -if no.quantity.present? && no.quantity.gsub(/[^0-9]/, '').to_i > 0 
       = #button_to 'В корзину', line_items_path(ART_ID: no), :remote => false, :class => "to-cart"  
       = #button_to 'В корзину2', line_items_path(ART: no.brand+" | "+no.article_nr+" | "+no.description, price: 11, distributor_id: no.distributor_id), :remote => false, :class => "to-cart" 
       = form_tag(line_items_path) do |f| 
       = hidden_field_tag 'ART', no.brand+" | "+no.article_nr+" | "+no.description 
       = #text_field_tag 'price', 11 
       = hidden_field_tag 'price', no.price 
       = hidden_field_tag 'distributor_id', no.distributor_id 
       = submit_tag "Upload", :class => "to-cart"  

    %br 
    - @articles.each do |art| 
     %tr{ :class => cycle("zebra-stripe zebra-grey zebra1", "zebra-stripe zebra-grey zebra2")}  
     %td 
      %h4 
      = art.supplier.SUP_BRAND 
      =# art.ART_ID 
     %td 
      = art.art_name 
      %h4 
      -if user_signed_in? 
       = art.ART_ARTICLE_NR 
      -else 
       = art.ART_ARTICLE_NR.first.concat("***").concat(art.ART_ARTICLE_NR.last)  
     %td 
      = link_to "подробнее/аналоги", art 
     %td 
      -if art.Quantity.present? && art.Quantity > 0 
      = #((art.Price.to_f - art.Price.to_f * @discont) * @eur_cur.currency_value).round(-1) 
      %h4 
      = #art.find_price(art.ART_ARTICLE_NR.gsub(/[^0-9A-Za-z]/, ''), art.supplier.SUP_BRAND, "price") 
      %p{ :nr => art.ART_ARTICLE_NR.gsub(/[^0-9A-Za-z]/, ''), :br => art.supplier.SUP_BRAND, :type => "price", :class => "priceclass", :id => art.ART_ARTICLE_NR.gsub(/[^0-9A-Za-z]/, '')} 
     %td 
      %p{ :nr => art.ART_ARTICLE_NR.gsub(/[^0-9A-Za-z]/, ''), :br => art.supplier.SUP_BRAND, :type => "quantity", :class => "qntclass", :id => art.ART_ARTICLE_NR.gsub(/[^0-9A-Za-z]/, '').concat("q")} 
     .logo 

     %td 
      %p{ :nr => art.ART_ARTICLE_NR.gsub(/[^0-9A-Za-z]/, ''), :br => art.supplier.SUP_BRAND, :type => "waittime", :class => "waittimeclass", :id => art.ART_ARTICLE_NR.gsub(/[^0-9A-Za-z]/, '').concat("w")} 
     %td 
      -if art.Quantity.present? && art.Quantity > 0 
      = #button_to 'В корзину', line_items_path(ART: art.supplier.SUP_BRAND+" | "+art.ART_ARTICLE_NR+" | "+art.art_name, price: 11), :remote => false, :class => "to-cart" 
      = form_tag(line_items_path) do |f| 
      = hidden_field_tag 'ART', art.supplier.SUP_BRAND+" | "+art.ART_ARTICLE_NR+" | "+art.art_name 
      = #text_field_tag 'price', 11 
      = hidden_field_tag 'price', 0, :id => art.ART_ARTICLE_NR.gsub(/[^0-9A-Za-z]/, '') 
      = hidden_field_tag 'distributor_id', 1 
      = submit_tag "Upload", :class => "to-cart" 
    - if @oem_art.is_a?(Array) 
     [email protected]_art.each do |oem| 
     %tr{ :class => cycle("zebra-stripe zebra-blue zebra1", "zebra-stripe zebra-blue zebra2")} 
      %td 
      %h4 
       =#oem[oem][:car] 


    .pagination_content 
    = paginate @articles 
    %h4 
    Не нашли необходимую запчасть? 
    = link_to "Сделать on-line запрос менеджеру", new_ask_vin_path 

내가 정상의 표를 참조해야한다고 생각하지만, 내가 할 첫 번째 [email protected]_original.each do |no| 같은

[#<PriceList id: 77845, distributor_id: 1, brand: "TECH-AS", article_nr: "110064Q", price: 3.0, quantity: ">8", waittime: 1, description: "110064Q (TO1341D) OX143D 1100696 AUDI/VW TDI", created_at: "2012-10-11 21:21:56", updated_at: "2012-10-11 21:21:56">, #<PriceList id: 7253, distributor_id: 1, brand: "CARGO", article_nr: "B140036", price: 0.0, quantity: "0", waittime: 1, description: "140036A 3471553 Del 12.08x14.08x14.00", created_at: "2012-10-11 09:36:26", updated_at: "2012-10-11 09:36:26">] 

그러나 그럼 내가 테이블 에서이 데이터를 볼 수 있습니다 ... 이것은 마술입니다) 어떻게 테이블 에서이 데이터를 볼 수 있습니까?

참조 스크린 샷 : screenshot

또한 내 컨트롤러는 다음과 같습니다

def get_parts_via_category 
    *****(secret)))) 
    @articles = Kaminari.paginate_array(@pre_articles).page(params[:page]).per(20) 

    @asdasd = ArtLookup.get_construction_number(@pre_articles.map(&:ART_ID)) 
    @constr_num = @asdasd.uniq{|x| x.ARL_SEARCH_NUMBER} 
    logger.warn("mE gusta !!!!!!") 
    non_original = [] 
    @pre_articles.each do |a| 
     logger.warn("SDFSDFS fsdf sdf sdfSDF SDF SD !!!!!!!!!!! dgfdfg d*fd*g fd-gd f") 
     a.logger.warn(a.supplier.SUP_BRAND.gsub(/[^0-9A-Za-z]/, '')) 
     norig = get_non_tecdoc(a.ART_ARTICLE_NR.to_s.gsub(/[^0-9A-Za-z]/, ''), 1, a.supplier.SUP_BRAND) 
     if norig.present? 
     non_original << norig 
     end  
    end 

    oem_art = [] 
    @constr_num.each do |o| 
     as_oem = get_from_as_oem(o.ARL_SEARCH_NUMBER) 
     if as_oem.present? 
     oem_art << as_oem 
     end 
    end  
    @non_original = non_original.uniq 
    @oem_art = oem_art.to_a.uniq 


    @eur_cur = Currency.find_by_currency_name("EUR") 
     @discont = 0 
    if user_signed_in? 
     @discont = 0.01 
     user = User.find(current_user.id) 
     @total = 0 
     for order in user.orders do 
     @total += order.totalcost 
     if @total >=0 && @total <= 1000000 
      @discont = 0.02 
     end 
     if @total >=1000000 && @total < 7000000 
      @discont = 0.1 
     end 
     if @total >=7000000 && @total < 10000000 
      @discont = 0.15 
     end 
     if @total >=10000000 
      @discont = 0.2 
     end 
     end 
    end 
    end 
+2

'=''에 교체 시도 -' 여기를 : @@@non_original.each do | no |' – jdoe

+0

@jdoe 흠, 좋은 생각 ... 대답으로 쓰십시오 ... 또한 간단한 언어로 말할 때 -와 =의 차이점은 무엇입니까? – brabertaser19

답변

1

귀하의 라인 :

[email protected]_original.each do |no| 
:

[email protected]_original.each do |no| 

- 기호로 시작해야합니다

당신이 당신이 블록 (do ... end 또는 { ... }) 전달하는 경우 배열 자체를 반환 each 방법의 결과 숨길 수 있습니다이 방법 :

[1,2,3].each{} # => [1, 2, 3]