
Ruby && RoR
johnny_hg
这个作者很懒,什么都没留下…
展开
专栏收录文章
- 默认排序
- 最新发布
- 最早发布
- 最多阅读
- 最少阅读
-
Ajax pagination
Ajax paginationttp://wiki.github.com/mislav/will_paginate/ajax-pagination This is the most popular feature request for will_paginate library. Reasons why the core library doesn’t support thi...原创 2009-10-21 17:13:53 · 176 阅读 · 0 评论 -
rails缓存Tips: 缓存js,css文件
4.缓存Tips: 缓存js,css文件请参考: http://railslab.newrelic.com/2009/01/22/page-responsiveness# Combining all your javascripts in production mode<%= javascript_include_tag :all, :cache...原创 2009-12-26 23:52:58 · 202 阅读 · 0 评论 -
强大的ruby模版:ERB
#http://stdlib.rubyonrails.org/[code="ruby"]require "erb" # Build template data class. class Product def initialize( code, name, desc, cost ) @code = code @name = name ...2009-10-28 15:55:47 · 1394 阅读 · 0 评论 -
布局变量
[code="ruby"]class FooController < ActionController:Base layout :figure_out_layout def figure_out_layout if action_name = ~ /pretty 'pretty' else ...2009-10-22 17:00:24 · 172 阅读 · 0 评论 -
如何在Rails的controller中取得URL中的anchor值
有人问,如何在Rails的控制器中取得URL中的锚点的值,这个需求比较奇特,以前没搞过,于是google了一把,在“Getting the # value”这个帖子看到有人有类似的问题,他说出了在controller中直接取不到的原因是“For normal links/urls the#anchor is a client side feature and is often no...原创 2009-10-22 16:14:37 · 200 阅读 · 0 评论 -
在Rails中使用缓存(码表)的方式
搞过Java的应该都晓得,经常会定义一些字典,然后将这些字典缓存带内存中以提高查询的效率和速度,也就是常说的缓存,有人叫码表.今天看看如何在Rails中实现类似的功能,思路是一样的,可以缓存在数组或者Hash里面,这里为了查找方便,我们选择使用Hash.也就是:如何创建一个变量从rails开始运行时初始化,一直维持到rails终止,而且对于每一个request都能共享的变量?1,首...原创 2009-10-22 16:12:57 · 221 阅读 · 0 评论 -
应用WillPaginate分页
WillPaginate这个插件很棒,以至于其取代了Rails中原有的Paginate方法,虽然看上其很简单,其实还是有不少技巧的,本篇用来记录我遇到的或者使用到的一些tips。1.直接使用paginate这个比较简单,也是使用的最多的,如下:Ruby代码def self.get_all_items_in_catelog( catelog_id,page,per...原创 2009-10-22 15:14:38 · 133 阅读 · 0 评论 -
Rails render partial collection
Rails 在 partial 中 传递 collection,默认的循环变量 是 partial的名字(约定)。或者你想改变变量名的话,可以使用 :as 参数声明一个变量。。。不能用惯性思想 for ...........in........等例如:之前错误的写法:partial : _feednews.html.erb <%= render :partial => ...原创 2009-10-21 17:39:25 · 173 阅读 · 0 评论 -
Rails 很好用的锚(anchor)标记
Rails 很好用的锚(anchor)标记 锚(anchor)标记 很好用,虽然现在一般好多都是 ajax 无刷新 更新。。但是如何 你没有 采用 ajax 方法提交数据和更新的话,那么 anchor是你的最佳选择了,看上去有点像ajax的效果anchor 说白了 就是 进入 这个 页面的时候, 定位到页面指定的部分,例如一个个人用户的界面,最下面是留言版,如果你采用传统...原创 2009-10-21 17:15:11 · 196 阅读 · 0 评论 -
ubuntu 如何自动开启小键盘数字键?
sudo apt-get install numlockxsudo vim /etc/rc.local 把下面的内容添加到最后那行的前面代码:if [ -x /usr/bin/numlockx ]; then numlockx onfi原创 2010-01-04 14:15:50 · 235 阅读 · 0 评论