RUBY ON RAILS
文章平均质量分 75
melin1204
这个作者很懒,什么都没留下…
展开
-
Rails 1.2新特性体验(String和Array)
1 获取指定位置的字符ruby 代码 >> "Finally, something useful!".at(6) => "y" 2 from 和 to (String)ruby 代码 >> "Chris the Person".from(6) => "the Person&qu2006-12-20 20:46:00 · 91 阅读 · 0 评论 -
Single Table Inheritance Tricks
Single table inheritance is an extremely powerful and extremely easy thing to do in rails. If you wanted to do this in java you would probably shoot yourself just designing it, but all that pain is re...2007-01-30 09:51:32 · 71 阅读 · 0 评论 -
13 Ways of Looking at a Ruby Symbol
1. A Ruby symbol is the name of something, not just a blob of textIn Ruby, we would generally use symbols when referring to things by name:find_speech(:gettysburg_address)But to represent large ...2007-02-06 19:18:02 · 89 阅读 · 0 评论 -
Changes in Ruby 1.9(链接)(想看1.9的新特性请进)
http://eigenclass.org/hiki.rb?Changes+in+Ruby+1.9非常好的一篇文章。2007-02-12 09:03:47 · 85 阅读 · 0 评论 -
Rails中的代理
Rails中的代理: Active Record中一个代理应用实例[code] class Greeter < ActiveRecord::Base def hello() "hello" end def goodbye() "goodbye" end end clas...2007-02-27 08:54:23 · 128 阅读 · 0 评论 -
rails缓存-part1
[b]转自:http://www.railsenvy.com/[/b]1 如果在开发模式下,缓寸是不可用的,需要改动配制启动缓存,在/config/environments/development.rb中设置 [code]config.action_controller.perform_caching = true;[/code]2 页面缓存 页面缓存是Rails最为F...2007-05-23 08:45:59 · 76 阅读 · 0 评论 -
rails缓存-part2
上一部分介绍了页面缓存.这部分住要介绍Action缓存,Fragment缓存,ActiveRecord缓存这几种缓存的效果为:[code] 1. Page Caching - Fastest 2. Action Caching - Next Fastest 3. Fragment Caching - Least Fast[/code]1Action缓存 Ac...2007-05-23 08:48:12 · 115 阅读 · 0 评论 -
RailsCasts 视频笔记
观看http://www.railscasts.com/中的视频时记得笔记,只有我自己才能看的懂 :D 1[code]class ProjectsController < ApplicationController def show @project = Project.find(param[:id]) @tasks = Task.find(:all,:conditions...2007-05-26 14:59:40 · 96 阅读 · 0 评论 -
ruby on rails 文章链接
[b]1:用策略模式替换继承。链接的文章,就是用继承替换了单表继承:[/b][url]http://www.last100meters.com/2007/6/1/clean-code-tutorial-use-a-strategy-pattern-instead-of-inheritance[/url][b]2:介绍回调callback[/b][url]http://recursi...2007-06-06 09:47:02 · 82 阅读 · 0 评论 -
Ruby on Rails Rake Tutorial转载
写的非常棒!提供一个链接希望对大家有帮助。[url]http://www.railsenvy.com/2007/6/11/ruby-on-rails-rake-tutorial[/url]2007-06-13 09:22:08 · 82 阅读 · 0 评论 -
ActiveSupport::CoreExtensions 学习笔记(一)
1 ActiveSupport::CoreExtensions::Array::Conversions 1:to_formatted_s(fromate=:default) 如果不指定参数,会把数组的每一个元素连接起来。[code] >> %w(a b).to_formatted_s => "ab"[/code] 如果指定了:db参数就会把数组元素的id用逗号连接...2007-01-23 16:34:47 · 111 阅读 · 0 评论 -
Ruby线程池
This is useful for a variety of scenarios. You create a thread pool, give it a maximum size, and pass a block to it everytime you need something processed. If all threads are busy, you block until a t...2007-01-16 17:47:24 · 607 阅读 · 0 评论 -
Rails 1.2新特性体验(Hash,Integer和class)
[b]1 stringify_keys and symbolize_keys[/b][code]>> { 'days' => 25, 'spirit' => 'giving', 'wallet' => 'empty' }.symbolize_keys=> {:wallet=>"empty", :spirit=>"giving", :days=>25}>> { 'system' => '2006-12-21 13:18:10 · 97 阅读 · 0 评论 -
Rails 1.2新特性体验(杂记)
1 Range#to_s(:db)[code]>> (7.days.ago..1.day.ago).to_s(:db)=> "BETWEEN '2006-12-11 02:06:50' AND '2006-12-17 02:06:50'" [/code]2 Time Calculations[code]>> Time.days_in_month(2)=> 28>> Ti...2006-12-21 19:16:38 · 117 阅读 · 0 评论 -
ActionRecord和ActionPack 配置
ActionRecord 配置[color=blue][b]整理出来方便查询[/b][/color]1.ActionRecord:Base.logger=logger 接受一个logger对象。改对象被内部使用。用于记录数据库的操作。如果应用程序须记录数据库操作,也会使用这个logger对象。2.ActionRecord:Base.primary_key_prefix_type=...2007-01-03 11:10:12 · 172 阅读 · 0 评论 -
Rails: Inner joins by association names
From http://habtm.com/articles/2006/05/10/inner-joins-by-association-names:We can enjoy eager loading with association names.[code]Member.find(:all, :include=>[:group, :profile])[/code]But :jo...2007-01-04 13:14:39 · 62 阅读 · 0 评论 -
Rails - Easily work with uppercase column names
我们在Oracle建的表和字段名字基本上是大写的。这对我们是非常有用的。I had to work with a legacy database with hundreds of tables with uppercase column names. Here is how I made my life a whole lot easier...[code]module ActiveR...2007-01-04 13:17:36 · 97 阅读 · 0 评论 -
Rails 命令大全
一.铁道1.1 创建一个Rails应用程序 $ rails app_name 可选项: -d, database=xxx 指定安装一个数据库(mysql oracle postgresql sqlite2 sqlite3 ), 默认情况下是数据库 -r, ruby-path= 指定Ruby的安装路径,如果没有指定,scripts使用env去找Ruby -f, freeze (冻结)f...2007-01-06 13:34:13 · 132 阅读 · 0 评论 -
Ruby代码片段!
1 foldr and foldl in Ruby ruby 代...2007-01-09 17:31:17 · 106 阅读 · 0 评论 -
Rails代码片段
1Debugging Views in Development ruby 代码 "debug" style="margin: 40px 5px 5px 5px;"> "#" onclick="Element.toggle('debug_info');return false" style=...2007-01-11 18:06:14 · 94 阅读 · 0 评论 -
一个非常不错的缓存方法,把缓存的结果放在数据库,节省内存!(转)
[b][url]http://www.bigbold.com/snippets/posts/show/3286[/url][/b]Rails memcached is not very easy to introduce to a large rails installation. Memcached also chews up a lot of memory on the box and ove...2007-01-16 17:25:08 · 509 阅读 · 0 评论 -
snippets-rails
[b]rails中数据库事务:[/b][code]def fetch_value sql = ActiveRecord::Base.connection(); sql.execute "SET autocommit=0"; sql.begin_db_transaction id, value = sql.execute("SELECT id, value FROM some...2007-09-22 00:36:06 · 61 阅读 · 0 评论