
ruby
iteye_16374
这个作者很懒,什么都没留下…
展开
专栏收录文章
- 默认排序
- 最新发布
- 最早发布
- 最多阅读
- 最少阅读
-
Create YAML test fixtures from database
转于[url]http://snippets.dzone.com/tag/yaml[/url][code]运行:cd #{RAILS_ROOT}/lib/tasks/rake db:fixtures:dump_allorrake db:fixtures:dump_referencesnamespace :db do namespace :fixtu...2007-12-18 16:53:00 · 100 阅读 · 0 评论 -
rails route
[code="java"] # ==== Relying on named routes # # If you instead of a hash pass a record (like an Active Record or Active Resource) as the options parameter, # you'll trigge...2008-06-26 11:55:03 · 324 阅读 · 0 评论 -
redcloth 安装至ruby on rails 项目中
1. 拷贝redcloth.rb到ror的lib目录内。2. 拷贝jstoolbar相关的javascript 、stylesheet、images到对应的public目录里面。另外把压缩包里的help目录完整地拷贝到public目录下,其是redcloth语法的使用帮助.3. 在application的helper方法中添加如下两个方法:[code="ruby"]req...2008-06-27 22:45:48 · 133 阅读 · 0 评论 -
rails魔术字段的实现 ,alias_method_chain用法,for classmethod
Encapsulates the common pattern of: alias_method :foo_without_feature, :foo alias_method :foo, :foo_with_featureWith this, you simply do: alias_method_chain :foo, :feature替我们定义了两个...2008-07-01 18:03:24 · 352 阅读 · 0 评论 -
(ruby)String Extensions(字符串、首字母大写,复数单数转换)
字符串截取,英文单词单数复数转换(Agile Web Development with Rails [Chapter 15||||||||||||||Active Support[P251])ruby 代码 string = "Now is the time" puts string.at(2) #=> "w" puts stri...2007-09-27 20:03:32 · 289 阅读 · 0 评论 -
logger (ruby)
apache 项目中的与log4j对应的ruby版为->log4rruby 代码 log = Logger.new(STDOUT) log.level = Logger::WARN log.debug("Created logger") log.info("Program started") log.warn("Nothing to do!") begin ...2007-09-28 14:57:28 · 126 阅读 · 0 评论 -
REST_RUBY_XML
#response to client respond_to do |wants| wants.html { redirect_to(person_list_url) } wants.js wants.xml { render :xml => @person.to_xml(:include => @compa...2007-10-08 20:07:58 · 86 阅读 · 0 评论 -
从域名到IP转换
[code="ruby"]#!/usr/bin/env ruby require 'open-uri' LOOKUP_URL = 'http://toolbar.netcraft.com/site_report?url=%s' MATCH_RE = /IP address([\d\.]+)/ host = ARGV.select { |arg| arg !~ ...原创 2007-10-13 08:37:29 · 216 阅读 · 0 评论 -
to_xml methods model add attributes
topic.to_xml(:skip_instruct => true, :except => [ :id, :bonus_time, :written_on, :replies_count ])更多方法参考API --> to_xml ActiveRecord::XmlSerializatio...2007-10-13 17:49:51 · 131 阅读 · 0 评论 -
ruby core search
如何使用类名来获得类?如果我有classname = "String时,如何生成SomeClass类的实例呢?主要有两个解决方法。"ruby 代码 [1] eval(classname).new [2] Object.const_get(classname).new 第1种方法既简单又可以处理嵌套类(Net::HTTP等),但如果在CGI环境中滥用它的话...2007-10-18 21:46:45 · 115 阅读 · 0 评论 -
lighttpd 服务器设置
1 。 在(ruby on rails) 的项目下面,确保public/目录中的 dispatch.fcgi , dispatch.cgi , dispatch.rb 三个文件中 1: 确保第一行内容为本机的ruby的安装目录 。(例如:我本机的是 #!/usr/local/ruby/bin/ruby ) 而在5.102上面,因为ruby 是默认安装...2007-11-19 12:23:11 · 316 阅读 · 0 评论 -
"No such file to load" 解决策略, ruby on rails 开发注意事项
[size=medium][b]服务器运行时解决[/b][/size] 先来总结吧! 在我们建立 rails 应用的时候,我们应该:[list=1][*]尽量把各种用到的插件放到RAILS_ROOT/vendor目录下面[*]当然我们的rails 应该把它放在RAILS_ROOT/vendor/rails目录下。[code="ruby"]rake rails:f...2008-10-29 18:16:49 · 290 阅读 · 0 评论 -
ruby 日期
[code="ruby"]difference = Time.now - time seconds = difference % 60 difference = (difference - seconds) / 60 minutes = difference % 60 difference = (difference - minutes)...2008-06-25 12:38:51 · 201 阅读 · 0 评论 -
sliceHost rails 空间 ror 主机
sliceHost 注册购买虚拟主机.[url]https://manage.slicehost.com/customers/new?referrer=951c40e184743beeb90436bb96ad9aba[/url]使用slicehost 。很简单的一个原因,自由~ 其它虚拟主机的提供商相比,拥有 root 的权限,一个独立的 IP, 真的有种为所欲为的感觉啊,呵呵。让你...2009-02-27 23:17:16 · 143 阅读 · 0 评论 -
ror opensource project开源rails应用
[list][*][b]warehouse[/b] 版本管理相关 http://www.warehouseapp.com/[*] [b]Boxroom[/b]sharing and managing files online 网上文件管理与分享应用 http://boxroom.rubyforge.org/[*][b]Osirails[/b] . 带有ERP...原创 2009-02-05 11:17:48 · 165 阅读 · 0 评论 -
File io read/write to a file
原本是想在以读写的方式打开一个文件,然后在此文件中查找相对应的字符并替换,起初偿试的是找到需要的字符后把文件的指针移动到此line的头位置,重写,然而重写的时候是replace而非insert,这样就导致了如果替换的字符小于或大于的时候,就会留下不能被替换掉。f = File.open("/root/Desktop/test.txt","r+")[code="ruby"]c=f...2008-01-10 17:24:26 · 120 阅读 · 0 评论 -
RJS Reference
[size=xx-large][color=indigo]JavaScriptGenerator[/color][/size]摘自:《OReilly.RJS.Templates.for.Rails.Jun.2006.chm》chapter 7[code="ruby"]The following is a list of all of the methods public met...2008-01-29 08:53:37 · 153 阅读 · 0 评论 -
Single table inheritance:单表继承
[align=center][size=x-large]Single table inheritance:单表继承[/size][/align]转于:[url]http://my4java.itpub.net/post/9983/78535[/url]一、介绍:关系数据库不支持继承,所以在将对象映射到数据库时,我们必须考虑如何在关系表中表现我们完美的继承结构。当映射到一...2008-03-07 16:34:50 · 215 阅读 · 0 评论 -
ruby 杂记
匹配网站中的脚本,并且按照其中的目录结构下载保存.[code="ruby"]require 'open-uri'url = 'http://www.feyasoft.com'root = '/root/Desktop/fey'open(url) do |f| f.each do |l| if l =~ // fil...2009-01-05 14:17:42 · 104 阅读 · 0 评论 -
render 页面javascript调用
情景:[code="java"]在使用 rail 中的 自动完成功能 auto_complete_field时,假若返回的页面中有 javascript脚本,那它将不会被返回。 必需把它用 javascript_function 方法进行改写。a.rhtml 中 render _b.rhtml 页面。 在_b.rhtml中如果包含了 javascript脚本,则不能被render到a....2008-04-03 17:18:57 · 745 阅读 · 0 评论 -
一个表单提交多条记录的处理(Ruby on Rails)
使用的是一个一对多关联,代码如下:view: partial名称:描述:rhtml:[code="ruby"]订单:物 品: 'mat', :url => {:action => :add_field }, :position => 'bottom' %> 'ma...2008-04-07 21:34:17 · 294 阅读 · 0 评论 -
HowToRunBackgroundJobsInRails--ap4r
http://ap4r.rubyforge.org/wiki/wiki.pl?GettingStarted [list=1][*]1. Business logics can be implemented as simple Web applications, or ruby code, whether it's called asynchronously or synchron...2008-04-09 16:59:47 · 107 阅读 · 0 评论 -
多对多关联数据存储ROR
[size=medium]Sku MODEL :[/size][code="ruby"]class Sku < ActiveRecord::Base has_and_belongs_to_many :records, :delete_sql=>'DELETE FROM skus_records WHERE sku_id= \'#{id}\' AND record_i...2008-04-22 10:16:33 · 190 阅读 · 0 评论 -
使用include中嵌Hash取出一个多层次的对象关联数据
使用include中嵌Hash取出一个多层次的对象关联数据.首先有如下关系:[code="ruby"]project issue : 一对多issue comment : 一对多comment history : 一对多Project [1] content) @issue_before_change = self.clone @current_...2008-05-22 16:09:45 · 143 阅读 · 0 评论 -
rails plugins 做一个电子商务系统
[size=large][b]第一阶段:[/b][/size] 把以下三个rails插件跑起来。[list][*][b]spree [/b][*][b]active_merchant [/b][*][b] OpenID_authentication_plugin:[/b][/list][b]gem update[/b][code="ruby"] gem...原创 2009-01-20 16:49:26 · 160 阅读 · 0 评论 -
Capistrano deploy.rb文件的记录
[code="ruby"]# 在redhat 内核中不需要sudo 方式运行。set :use_sudo, false # Do not use sudo ro run command.set :domain, 'www.firebirds.com' set :application, 'ruby_on_rails'set :user, 'root' # connect ...2008-11-18 19:57:08 · 198 阅读 · 0 评论