@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
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
救命啊
monaco
#3 楼 @Rei undefined method `id' for #ActiveRecord::Relation:0xb66472f4
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 就为空数组了
哦,其他控制器都是继承的这个控制器
用了一段时间 sublime text 2,感觉很多地方还是没有 vim 用着顺手,现在不用他了
用 linux 才有感觉,free 的感觉
难道因为这个原因你不想出生在中国吗
是要改数据库吗?
#4 楼 @gaicitadie 嘿嘿
rails.vim zencoding.vim command-T
就是 关系吧
看起了要求很高
学了几天了,现在也是迷茫中
没事