翻阅本书的读者,相信您对Ruby on Rails并不陌生。Ruby on Rails的创造者DHH曾被2005年“全球开源大会”(OSCON)评为“年度最佳黑客”,《连线》杂志封面人物更将其标榜为“地球上最炙手可热的黑客”。而他与Dave Thomas合著的另一部…
对英文网站,我们常常需要显示一个名词的复数形式。
而Rails就提供了一个称为Inflector的工具来计算该逻辑,并且ActionView有一个wrapper方法来处理常见的复数形式,如:
[code]
There are <% pluralize recipes.size, "recipe" %&…
字符串和正则表达式与国际化关系紧密,utf-8可以让我们轻松搞定国际化问题
关于Unicode和utf-8入门,请看[urlhttp://hideto.iteye.com/blog/97803]深入了解字符集和编码[/url][b]
Internally, a string is just a series of bytes.
在系统内部,…
我们看看config/environment.rb文件,其中有以下一段:
[code]# Use the database for sessions instead of the file system# (create the session table with rake db:sessions:create)# config.action_controller.session_store :active_record_store
[/code]
Rai…
[urlhttp://hideto.iteye.com/blog/81339]Dealing With Time-zones[/url]一文中介绍了Rails的TimeZone类,它可以用来转换不同时区的本地时间
今天看看tzinfo_timezone插件,它是对[urlhttp://tzinfo.rubyforge.org]TZInfo[/url]库的封装,我们需…
Rails测试分三种:
1,关注于一个单独的Model的单元测试Unit test
2,关注于一个单独的Controller和它使用的models之间的交互的功能测试Functional test
3,关注story级的多个controllers的多个actions之间的交互的集成测试Integration test
今天…
原文: [urlhttp://jimneath.org/2008/04/25/building-a-social-network-site-in-rails/]Building a Social Network Site in Rails[/url]本文不会手把手教你如何实现一个社会化网络站点,而是覆盖一些你可能认为有用的插件和事情。[colorred][b]社会化网络插件[/b][/…
如果我们想根据模板页面更改局部layout,使用content_for即可。
content_for允许模板页面代码放到layout中的任何位置。比如我们的Rails程序不同的页面有不同的css样式,我们可以在layout里留出位置:
[code]
<!DOCTYPE html PUBLIC "-//W3C//DTD X…
install:
[code]
./script/plugin install svn://rubyforge.org/var/svn/nested-layouts/trunk/nested_layouts
[/code]doc:
[url]http://nested-layouts.rubyforge.org/[/url]Anyway, its a little ugly.
首先看看代码:
reqdemo.rb
[code]
puts "This is the first (master) program file."
require "requiree.rb
require "requiree.rb
puts "And back again to the first file."
[/code]
loaddemo.rb
[code]
puts "This is the first (master…
[urlhttp://beast.caboo.se/]Beast[/url] is a small, light-weight forum in Rails with a scary name and a goal of around 500 lines of code when were done.[urlhttp://beast.caboo.se/forums/1/topics/381]Getting Started with Beast:[/url]
1,下载源码
[co…
Tram Time Limit: 1000MS Memory Limit: 30000K Total Submissions: 7135 Accepted: 2583 题目链接:http://poj.org/problem?id1847
Description
Tram network in Zagrebconsists of a number of intersections and rails connecting some of them. Inevery …
今天来看看使用upload_progress插件监听文件上传status以及创建AJAX上传progress bar
Requirements:[url]http://sean.treadway.info/articles/2005/07/18/upload-progress-checklist[/url]安装好该插件以及Requirements后,我们就可以在controller里使用了:
[code]
…
这次来介绍ActiveSupport里对Symbol的扩展,我们先来看active_support/core_ext/symbol.rb文件:
[code]
class Symbol# Turns the symbol into a simple proc, which is especially useful for enumerations. Examples:## # The same as people.collect { |p| p.name…
作者: Ray Linn 最后更新:2010/07/19[b]引用.NET的Assembly[/b]
除了我们前面提到的require <PartialName> 和require <Strong name>外,Ironruby 1.0发布的时候,还提供了一个新的函数load_assembly,这个函数的参数为A…
REST(Representational State Transfer)是一种针对网络应用的设计和开发方式,可以降低开发的复杂性,提高系统的可伸缩性。REST提出了一些设计概念和准则: 网络上的所有事物都被抽象为资源(resource); 每个资源…
前面的一篇文章[urlhttp://hideto.iteye.com/blog/81579]每天一剂Rails良药之Syndicate Your Site With RSS[/url]中我们看了怎样手动创建RSS
今天我们来看看Rails开发组提供的一个atom_feed_helper插件,它使得创建atom feeds更容易首先安装atom_feed_helper插件
[c…
我可不是标题党,题目是原作者起的
[urlhttp://www.thirdbit.net/articles/2007/08/01/10-things-you-should-know-about-method_missing/]10 things you should know about method_missing[/url]1,method_missing是一个Ruby内核方法2,Rails使…
作者:Curt Hibbs 日期:10/13/2005译者:吴海燕 日期: 7/12/2005Ruby on Rails
Ruby on Rails是一套用Ruby写的Web应用程序框架,Ruby是一个与Python,Smalltalk和Perl相似的动态语言。
本文内容:
什么是Ruby on …
Rails的fixture文件在传递给YAML解析之前先用ERB解析,这样一来我们就可以使用Ruby代码动态生成测试数据,而不用一条数据一条数据的写了:
[code]
<% 1.upto(50) do |number| %>
child_post_<% number %>:id: <% number 3 %>title: Thi…
原文:[urlhttp://www.highscalability.com/scaling-twitter-making-twitter-10000-percent-faster]Scaling Twitter: Making Twitter 1000 Percent Faster[/url]Twitter是目前为止最大的Ruby on Rails应用,几个月间页面点击由0增长到几百万,现…
將Redmine架在sub-URI參考HowTo Install Redmine in a sub-URI及Defect #32318,在config/environment.rb檔案的最底下加上:
ActionController::Base.relative_url_root RedmineApp::Application.routes.default_scope
Redmine::Utils::relative_url_ro…
Ruby On Rails 路径穿越与任意文件读取漏洞(CVE-2018-3760、CVE-2019-5418) "你知道深爱是什么感觉吗?" "就像房间突然黑了,我不是去找灯而是去找他。"漏洞概述:
Ruby on Rails(或者简称 Rails)…