- 浏览: 2048474 次
- 性别:
- 来自: NYC
文章分类
- 全部博客 (628)
- Linux (53)
- RubyOnRails (294)
- HTML (8)
- 手册指南 (5)
- Mysql (14)
- PHP (3)
- Rails 汇总 (13)
- 读书 (22)
- plugin 插件介绍与应用 (12)
- Flex (2)
- Ruby技巧 (7)
- Gem包介绍 (1)
- javascript Jquery ext prototype (21)
- IT生活 (6)
- 小工具 (4)
- PHP 部署 drupal (1)
- javascript Jquery sort plugin 插件 (2)
- iphone siri ios (1)
- Ruby On Rails (106)
- 编程概念 (1)
- Unit Test (4)
- Ruby 1.9 (24)
- rake (1)
- Postgresql (6)
- ruby (5)
- respond_to? (1)
- method_missing (1)
- git (8)
- Rspec (1)
- ios (1)
- jquery (1)
- Sinatra (1)
最新评论
-
dadadada2x:
user模型里加上 protected def email ...
流行的权限管理 gem devise的定制 -
Sev7en_jun:
shrekting 写道var pattern = /^(0| ...
强悍的ip格式 正则表达式验证 -
jiasanshou:
好文章!!!
RPM包rpmbuild SPEC文件深度说明 -
寻得乐中乐:
link_to其实就是个a标签,使用css控制,添加一个参数: ...
Rails在link_to中加参数 -
aiafei0001:
完全看不懂,不知所然.能表达清楚一点?
"$ is not defined" 的问题怎么办
查询是mongo mapper的
之后变成
def search_followers options, index options = inner_option_convert options follow_list = options[:searchterm].blank? ? index.followers_and_dates : index.followers_and_dates.find_all{|follow| follow[:follower].email =~ /.*#{options[:searchterm]}.*/} follow_list = follow_list.sort_by{|follow| follow[:follower].email} if options[:sort_by] == 'name' follow_list = follow_list.sort_by{|follow| follow[:date]} if options[:sort_by] == 'date' follow_list.collect{|follow| follow[:follower]}.paginate( options ) end def search_alerts options, index options = inner_option_convert options alert_list = index.alerts alert_list = alert_list.sort_by{|alert| alert.created_at} if options[:sort_by] == 'date' alert_list = alert_list.sort_by{|alert| alert.alert_rule._type } if options[:sort_by] == 'type' alert_list = alert_list.collect{|alert| alert if alert.category == options[:filter]}.compact unless options[:filter] == 'all' alert_list.paginate( options ) end
之后变成
def search_followers options, index options = inner_option_convert options if options[:sort_by] == 'date' u_ids = User.all( :conditions => {:email => /.*#{options[:searchterm]}.*/i }).map(&:id) following = Following.all( :conditions => { :index_id => index.id, :follower_id.in => u_ids }, :order => "created_at desc") f_ids = following.map(&:follower_id) user_hash = User.find(f_ids).group_by(&:id) f_ids.collect{|id| user_hash[id][0]}.paginate( options ) else f_ids = Following.all( :conditions => { "index_id" => index.id }).map(&:follower_id) User.all( :conditions => {:email => /.*#{options[:searchterm]}.*/i, :id.in => f_ids }, :order => 'email asc').paginate( options ) end end def search_alerts options, index options = inner_option_convert options sort_by = case options[:sort_by] when 'type' : 'category asc' else 'created_at desc' end condition= { "index_id" => index.id } condition["category"] = options[:filter] unless options[:filter].blank? or options[:filter] == 'all' alert_list = Alert::Alert.all( :conditions => condition, :order=> sort_by ) alert_list.paginate( options ) end
发表评论
-
Destroying a Postgres DB on Heroku
2013-04-24 10:58 887heroku pg:reset DATABASE -
VIM ctags setup ack
2012-04-17 22:13 3212reference ctags --extra=+f --e ... -
alias_method_chain方法在3.1以后的替代使用方式
2012-02-04 02:14 3237alias_method_chain() 是rails里的一个 ... -
一些快速解决的问题
2012-01-19 12:35 1432问题如下: 引用Could not open library ... -
API service 安全问题
2011-12-04 08:47 1340这是一个长期关注的课题 rest api Service的 ... -
Module方法调用好不好
2011-11-20 01:58 1297以前说,用module给class加singleton方法,和 ... -
一个ajax和rails交互的例子
2011-11-19 01:53 1855首先,这里用了一个,query信息解析的包,如下 https: ... -
Rails 返回hash给javascript
2011-11-19 01:43 2234这是一个特别的,不太正统的需求, 因为,大部分时候,ajax的 ... -
关于Rubymine
2011-11-18 23:21 2224开个帖子收集有关使用上的问题 前一段时间,看到半价就买了。想 ... -
ruby中和javascript中,动态方法的创建
2011-11-18 21:01 1190class Klass def hello(*args) ... -
textmate快捷键 汇总
2011-11-16 07:20 8086TextMate 列编辑模式 按住 Alt 键,用鼠标选择要 ... -
Ruby面试系列六,面试继续面试
2011-11-15 05:55 1973刚才受到打击了,充分报漏了自己基础不扎实,不肯向虎炮等兄弟学习 ... -
说说sharding
2011-11-13 00:53 1432这个东西一面试就有人 ... -
rails面试碎碎念
2011-11-12 23:51 1894面试继续面试 又有问ru ... -
最通常的git push reject 和non-fast forward是因为
2011-11-12 23:29 17144git push To git@github.com:use ... -
Rails 自身的many to many关系 self has_many
2011-11-12 01:43 2675简单点的 #注意外键在person上people: id ... -
Rails 3下的 in place editor edit in place
2011-11-12 01:20 909第一个版本 http://code.google.com/p ... -
Heroku 的诡异问题集合
2011-11-11 07:22 1655开个Post记录,在用heroku过程中的一些诡异问题和要注意 ... -
SCSS 和 SASS 和 HAML 和CoffeeScript
2011-11-07 07:52 12898Asset Pipeline 提供了内建 ... -
Invalid gemspec because of the date format in specification
2011-11-07 02:14 2068又是这个date format的错误。 上次出错忘了,记录下 ...
相关推荐
一个用Ruby on Rails搭建的图片分享的网站项目.完整源代码
详细介绍了rails性能优化的方方面面,对于性能调优有一定的帮助。
GoOnRails: 一个Rails生成器用于生成Go代码并集成Go APIs至一个Rails app中
复杂Rails系统架构优化
Ruby on Rails源代码
程序 博文链接:https://zhangjingqiang.iteye.com/blog/47041
Ruby on Rails入门经典代码,非常适合新手学习使用
Ruby on Rails入门经典-例子,有很多rails工程实例。
Rbuy for Rails源代码
RailsAdmin - 一个Rails引擎,提供了一个易于使用的界面来管理您的数据
对rails架构的代码分析,是一个非常有价值的资料,特意从网上收集并整理成一个文档
rails 项目起步示例 同新手共同进步
rails向导
Beginning Ruby on rails 源代码
简介 Ruby On Rails 框架自它提出之日...Rails 是一个真正彻底的 MVC(Model-View-Controller) 框架,Rails 清楚地将你的模型的代码与你的控制器的应用逻辑从 View 代码中分离出来。Rails 开发人员很少或者可能从未遇到
一个Rails应用程序,为DIY小型内容分发网络CDN提供支持
ruby_on_rails 开发者实战 源代码上 1-12章 来之不易啊。仅供学习.
《Rails之道》详细讨论了Rails的程序代码并通过分析Rails中的代码片段来深入解释它的功能,同时,《Rails之道》部分章节也摘录了一些API文档中的内容,使读者能够快速地找到对应的API文档、相关的示例代码以及深入...
web开发敏捷之道-rails第二版,下载后因为版本的更新已经程序登录上的一些问题进行的代码调整。目前在最新版本上可以运行
这几天一直在学习使用RoR(Ruby on Rails),想建立一个功能全面一点的LBS(Location Based Service)网站。但是对于我这个RoR的初学者(仅有几天时间)来说,毕竟太复杂了。因此本文试图简化原来的设计思路,抛弃一切...