`
fei1985
  • 浏览: 34388 次
  • 性别: Icon_minigender_1
  • 来自: 济南
最近访客 更多访客>>
社区版块
存档分类
最新评论
文章列表
module Config mattr_accessor :hostname mattr_accessor :admin_email end #s short for: module Config def self.hostname @@hostname end def self.hostname=(hostname) @@hostname = hostname end def self.admin_email @@admin_email end def self.admin_email=(admi ...
使用facebox时, 我们要点击关闭按钮时, 遮罩层才消失, 默认是没有这个功能的.这个功能很简单,就是阻止关闭事件的触发就行了. 首先在settings加入默认值,方便我们使用的时候定置效果 settings: { opacity : 0, overlay : true, modal : true, loadingImage : '/images/facebox/loading.gif', closeImage : '/images/facebox/closelabel.gif', im ...
time formate  Time::DATE_FORMATS[:month_and_year] = "%B %Y" Time::DATE_FORMATS[:short_ordinal] = lambda { |time| time.strftime("%B #{time.day.ordinalize}") } error_messages     ActionView::Base.field_error_proc = Proc.new{ |html_tag, instance| html_tag } 在rails3中要加html_sa ...
  在源文件中看到新的写法 和前面相差很多, 不过老方案在rails3也不会出错   Examples of using the default rails validators:   validates :terms, :acceptance => true   validates :password, :confirmation => true   validates :username, :exclusion => { :in => %w(admin superuser) }   validates :email, :format => { :w ...

关于returning

在beast的记录中看到一个方面中用到returning的用法。   def reply(topic, body) returning topic.posts.build(:body => body) do |post| post.forum = topic.forum post.user = self post.save end end  有点不是很理解。在google中收到这篇文章是关于returning的说明的 http://weblog.jamisbuck.org/2006/10/27/mining-a ...
http://www.letrails.cn/archives/difference-between-for-loop-and-each/  上看到   for和each的区别主要在于: for是通过调用each实现,因此for更慢一些 for会在each的scope之外创建一个局部变量,这在某些情况下会引发问题 关于第二点,下面的代码可以很好的说明这个问题: irb> [1, 2, 3].each do |m| puts m end irb> puts m NameError: undefined local variable or method ...
rails3 路由发生了剧大的变化, 是居于项目名称的 Redmine::Application.routes.draw do |map| rest路由eg. resources :trackers #简单路由:  match '/projects#edit' => 'projects#settings' #post方法的路由:  post "my/order_blocks" #get 方法的路由: get "/my/page" #namespace 路由     namespace :admin do      ...
  In short, passing options hash containing :conditions, :include, :joins, :limit, :offset, :order, :select, :readonly, :group, :having, :from, :lock to any of the ActiveRecord provided class methods, is now deprecated. Going into details, currently ActiveRecord provides the following finde ...
ruby是灵活的,同样的效果花的代价却是不同的请看下面的例子:   require 'benchmark' Benchmark.bm do|b| b.report("without .nil?") do cat = nil bat = 'vampire' 2_000_000.times do unless bat true if cat end end end b.report("with nil? ") d ...
    1、关键词 关键词在网站TITLE上的使用     2、外部链接 外部链接的锚文字     3、网站品质 网站的外部链接流行度、广泛度     4、网站品质 域名年龄(从被搜索引擎索引开始计算)     5、页面质量 网站内部链接结 ...
    jQuery 1.3中新增的方法。给所有当前以及将来会匹配的元素绑定一个事件处理函数(比如click事件)。也能绑定自定义事件。    目前支持 click, dblclick, mousedown, mouseup, mousemove, mouseover, mouseout, keydown, keypress, keyup。   还不支持 blur, focus, mouseenter, mouseleave, change, submit ,与bind()不同的是,live()一次只能绑定一个事件。       这个方法跟传统的bind很像,区别 ...
mysql的速度优化中,我们首先从硬件来提高我们的 mysql的速度。常见的系统瓶颈如下 磁盘搜索。需要花时间从磁盘上找到一个数据,优化它的方法是将数据分布在多个磁盘上,组成磁盘矩阵,提升了更高的存储性能,也提高了数据的安全性。 磁盘读/ 写。对于现代的磁盘,一个磁盘至少传输10-20Mb/s 的吞吐。提高磁盘的速度提升myql. CPU 周期。周期越小,从内存中读写的数据越高 内存大小。当然是越大载好了。当然内存还有很多参数了。 总体来说 性能强的机器mysql的运行速度也越高。当然这个需要G的支持,大部份情况下我们应该优化数据库表的设计,相关系统参数配置,相关mysq ...
1,总是从ID选择器开始继承 2,在class前使用tag(标签名) 3,将jQuery对象缓存起来(在多次使用是,用一个中间变量代替,而不是总是用选择器)   4,对直接的DOM操作进行限制 5,注意尽量减少事件冒泡 6,推迟到 $(window).load   7,压缩JavaScript 8,尽量使用ID代替Class。 9,给选择器一个上下文   10,慎用 .live()方法(应该说尽量不要使用) 11,子选择器和后代选择器   12,使用data()方法存储临时变量
有能不全 常用效果 page.insert_html :bottom, "list", "<li>hello</li>" page.visual_effect :highlight, "list" page.hide "list" page.remove "list" page.replace "id", :partial => "template" page.replace_html "id" ...
有时一些结果长度的判定。   选择有很多,像size, length, empty?,any?等等   如果在controller.rb 你有了 @users = User.activate   在view中   1.使用size   if @users.size > 0   会产生2条sql     但length不会        
Global site tag (gtag.js) - Google Analytics