• #2 楼 @eddie 嗯,看看

  • 预览

  • @categ.each_with_index do |e,i|
      if i != 0
        @videos << Video.includes(:videodatum).where(:cid => e).order('lastdate DESC').limit(5)
        # @tops << Video.joins('LEFT OUTER JOIN videodata ON videodata.video_id = videos.id').where(:cid => e).order('hits DESC').limit(10)
        @tops << Video.includes(:videodatum).where(:cid => e).order('videodata.hits DESC').limit(10)
    
      end
    end
    
  • #10 楼 @Rei 嗯,现在好了

    Started GET "/" for 127.0.0.1 at 2012-06-26 20:32:19 +0800
    Processing by VideosController#index as HTML
      Categorgy Load (2.1ms)  SELECT `categorgies`.* FROM `categorgies` ORDER BY cup
      Rendered videos/_toolbar.html.erb (0.1ms)
      Video Load (5.8ms)  SELECT `videos`.* FROM `videos` WHERE `videos`.`cid` IN (5, 6, 7, 8, 9, 10, 11) ORDER BY lastdate DESC LIMIT 5
      Videodatum Load (1.6ms)  SELECT `videodata`.* FROM `videodata` WHERE `videodata`.`video_id` IN (1041, 1039, 1036, 1000, 1037)
      Video Load (4.8ms)  SELECT `videos`.* FROM `videos` WHERE `videos`.`cid` IN (13, 15, 16, 17, 37) ORDER BY lastdate DESC LIMIT 5
      Videodatum Load (1.8ms)  SELECT `videodata`.* FROM `videodata` WHERE `videodata`.`video_id` IN (1033, 941, 943, 942, 929)
      Video Load (6.7ms)  SELECT `videos`.* FROM `videos` WHERE `videos`.`cid` IN (32, 20, 30) ORDER BY lastdate DESC LIMIT 5
      Videodatum Load (1.5ms)  SELECT `videodata`.* FROM `videodata` WHERE `videodata`.`video_id` IN (776, 672, 947, 930, 866)
      Video Load (3.7ms)  SELECT `videos`.* FROM `videos` WHERE `videos`.`cid` IN (29, 33, 34) ORDER BY lastdate DESC LIMIT 5
      Videodatum Load (1.5ms)  SELECT `videodata`.* FROM `videodata` WHERE `videodata`.`video_id` IN (1040, 491, 925, 924, 923)
      SQL (34.0ms)  SELECT `videos`.`id` AS t0_r0, `videos`.`cid` AS t0_r1, `videos`.`nid` AS t0_r2, `videos`.`author` AS t0_r3, `videos`.`authorid` AS t0_r4, `videos`.`postdate` AS t0_r5, `videos`.`lastdate` AS t0_r6, `videos`.`name` AS t0_r7, `videos`.`picfolder` AS t0_r8, `videos`.`pic` AS t0_r9, `videos`.`playactor` AS t0_r10, `videos`.`director` AS t0_r11, `videos`.`tag` AS t0_r12, `videos`.`year` AS t0_r13, `videos`.`description` AS t0_r14, `videos`.`best` AS t0_r15, `videos`.`serialise` AS t0_r16, `videos`.`memo` AS t0_r17, `videos`.`yz` AS t0_r18, `videodata`.`video_id` AS t1_r0, `videodata`.`hits` AS t1_r1, `videodata`.`reply` AS t1_r2, `videodata`.`sale` AS t1_r3, `videodata`.`need` AS t1_r4, `videodata`.`usernth` AS t1_r5, `videodata`.`fraction` AS t1_r6, `videodata`.`star` AS t1_r7 FROM `videos` LEFT OUTER JOIN `videodata` ON `videodata`.`video_id` = `videos`.`id` WHERE `videos`.`cid` IN (5, 6, 7, 8, 9, 10, 11) ORDER BY videodata.hits DESC LIMIT 10
      SQL (11.6ms)  SELECT `videos`.`id` AS t0_r0, `videos`.`cid` AS t0_r1, `videos`.`nid` AS t0_r2, `videos`.`author` AS t0_r3, `videos`.`authorid` AS t0_r4, `videos`.`postdate` AS t0_r5, `videos`.`lastdate` AS t0_r6, `videos`.`name` AS t0_r7, `videos`.`picfolder` AS t0_r8, `videos`.`pic` AS t0_r9, `videos`.`playactor` AS t0_r10, `videos`.`director` AS t0_r11, `videos`.`tag` AS t0_r12, `videos`.`year` AS t0_r13, `videos`.`description` AS t0_r14, `videos`.`best` AS t0_r15, `videos`.`serialise` AS t0_r16, `videos`.`memo` AS t0_r17, `videos`.`yz` AS t0_r18, `videodata`.`video_id` AS t1_r0, `videodata`.`hits` AS t1_r1, `videodata`.`reply` AS t1_r2, `videodata`.`sale` AS t1_r3, `videodata`.`need` AS t1_r4, `videodata`.`usernth` AS t1_r5, `videodata`.`fraction` AS t1_r6, `videodata`.`star` AS t1_r7 FROM `videos` LEFT OUTER JOIN `videodata` ON `videodata`.`video_id` = `videos`.`id` WHERE `videos`.`cid` IN (13, 15, 16, 17, 37) ORDER BY videodata.hits DESC LIMIT 10
      SQL (16.7ms)  SELECT `videos`.`id` AS t0_r0, `videos`.`cid` AS t0_r1, `videos`.`nid` AS t0_r2, `videos`.`author` AS t0_r3, `videos`.`authorid` AS t0_r4, `videos`.`postdate` AS t0_r5, `videos`.`lastdate` AS t0_r6, `videos`.`name` AS t0_r7, `videos`.`picfolder` AS t0_r8, `videos`.`pic` AS t0_r9, `videos`.`playactor` AS t0_r10, `videos`.`director` AS t0_r11, `videos`.`tag` AS t0_r12, `videos`.`year` AS t0_r13, `videos`.`description` AS t0_r14, `videos`.`best` AS t0_r15, `videos`.`serialise` AS t0_r16, `videos`.`memo` AS t0_r17, `videos`.`yz` AS t0_r18, `videodata`.`video_id` AS t1_r0, `videodata`.`hits` AS t1_r1, `videodata`.`reply` AS t1_r2, `videodata`.`sale` AS t1_r3, `videodata`.`need` AS t1_r4, `videodata`.`usernth` AS t1_r5, `videodata`.`fraction` AS t1_r6, `videodata`.`star` AS t1_r7 FROM `videos` LEFT OUTER JOIN `videodata` ON `videodata`.`video_id` = `videos`.`id` WHERE `videos`.`cid` IN (32, 20, 30) ORDER BY videodata.hits DESC LIMIT 10
      SQL (15.6ms)  SELECT `videos`.`id` AS t0_r0, `videos`.`cid` AS t0_r1, `videos`.`nid` AS t0_r2, `videos`.`author` AS t0_r3, `videos`.`authorid` AS t0_r4, `videos`.`postdate` AS t0_r5, `videos`.`lastdate` AS t0_r6, `videos`.`name` AS t0_r7, `videos`.`picfolder` AS t0_r8, `videos`.`pic` AS t0_r9, `videos`.`playactor` AS t0_r10, `videos`.`director` AS t0_r11, `videos`.`tag` AS t0_r12, `videos`.`year` AS t0_r13, `videos`.`description` AS t0_r14, `videos`.`best` AS t0_r15, `videos`.`serialise` AS t0_r16, `videos`.`memo` AS t0_r17, `videos`.`yz` AS t0_r18, `videodata`.`video_id` AS t1_r0, `videodata`.`hits` AS t1_r1, `videodata`.`reply` AS t1_r2, `videodata`.`sale` AS t1_r3, `videodata`.`need` AS t1_r4, `videodata`.`usernth` AS t1_r5, `videodata`.`fraction` AS t1_r6, `videodata`.`star` AS t1_r7 FROM `videos` LEFT OUTER JOIN `videodata` ON `videodata`.`video_id` = `videos`.`id` WHERE `videos`.`cid` IN (29, 33, 34) ORDER BY videodata.hits DESC LIMIT 10
      Rendered videos/_sidebar.html.erb (119.0ms)
      Rendered videos/index.html.erb within layouts/application (410.0ms)
    Completed 200 OK in 532ms (Views: 286.4ms | ActiveRecord: 154.0ms)
    [2012-06-26 20:32:20] WARN  Could not determine content-length of response body. Set content-length of the response or set Response#chunked = true
    
  • #7 楼 @Rei 我看了一下,返回的数据现在是正常的,但是不知道为什么不用 id

  • #7 楼 @Rei undefined method `id' for #ActiveRecord::Relation:0xb66472f4

  • 救命啊

  • monaco

  • #3 楼 @Rei undefined method `id' for #ActiveRecord::Relation:0xb66472f4

  • #3 楼 @Rei 没有 videodata.hits 这个字段

  • #1 楼 @Rei 他的复数是 videodata

  • @ywencn

    class ApplicationController < ActionController::Base
      protect_from_forgery
      def self.get_categ
         ...
         categ
      end
    
    
    @@categ=self.get_categ if not defined?@@categ
    end
    

    @@categ 是数组

    然后我在其他控制器里使用@@categ,为什么只有第一次访问的时候正常,再访问是@@categ 就为空数组了

  • 哦,其他控制器都是继承的这个控制器

  • #20 楼 @camel 试了一下,很不错

  • #45 楼 @ery 不知道是大一还是大二开始用的,现在因该有两年了

  • #8 楼 @camel command-T

  • 用了一段时间 sublime text 2,感觉很多地方还是没有 vim 用着顺手,现在不用他了

  • 用 linux 才有感觉,free 的感觉

  • #1 楼 @veggie 感谢,试试

  • 难道因为这个原因你不想出生在中国吗

  • 是要改数据库吗?

  • rails.vim zencoding.vim command-T

  • #2 楼 @hooopo 嗯,试试

  • 就是 关系吧

  • 看起了要求很高

  • 学了几天了,现在也是迷茫中

  • 没事

  • ubuntu 12.04 gnome3

  • rails 路由的问题 at 2012年06月19日

    #3 楼 @yggg 恩,学习了