app/models/part.rb class Part < ActiveRecord::Base def after_create raise "no way" if self.name == "test" end end app/controllers/parts_controller.rb class PartsController < ApplicationController def test Part.create!(:name => "test") end end test/functional ...
agideo@ats1:~/apps/app_name$ ruby script/server -e production => Booting Mongrel (use 'script/server webrick' to force WEBrick) => Rails application starting on http://0.0.0.0:3000 => Call with -d to detach => Ctrl-C to shutdown server ** Starting Mongrel listening at 0.0.0.0:3000 ** Starting Rails ...
x = "abc" y = x x = "xyz" puts y # abc xx = "abc" yy = xx xx.gsub!(/c/, 'a') puts yy # aba
  • 09:39
  • 浏览 (106)
  • 评论 (3)
# app\controllers\examples_controller.rb ruby 代码   class ExamplesController < ApplicationController        def ajax_select       @items = %w{AA BB}   &n ...
1. 经常出现是的本机的 rake test 正常 但是 CC上却是错的,  花了N个小时后发现是 少了一个fixtures 原因是 本机与CC 服务器加载CC的顺序不一样. 随手写一个rake  来解决这个问题 ruby 代码   namespace :test do     task :each_file do          &n ...
在其它文章中看到 用rails ubuntu 性能最好 目前的项目 rake test 的速度让人受不了 就在自己家的电脑上小试了一把. 环境 CPU  赛扬 2.0 内存 512M 硬盘1 Ubuntu 7.04  (已经升级过了 到 7.10) Rails 1.2.2 mysql  Ver 14.12 Distrib 5.0.38, for pc-linux-gnu (i486) using readline 5.2 ruby 1.8.5 (2006-08-25) [i486-linux] 硬盘2 windows xp&n ...
新建一个 *.vbs 文件将以下两句复制进去 Set shell = Wscript.createobject("wscript.shell") a = shell.run ("c:\windows\msdot\auto.bat",0) OK了 另外 1、#隐藏窗口; 2、#普通激活; 3、#最小化激活; 4、#最大化激活; 5、#普通不激活; 6、#最小化不激活。如果省略本参数,默认为“普通激活”方式。 - delphi winexec(pchar(Extract ...
  • 17:04
  • 浏览 (1010)
  • 评论 (10)
单元测试中 product.errors.invalid? 的用法 p 181 # product.rb validates_presence_of :title def test_invalid_with_empty+attributes   product = Product.new   assert !product.valid?   assert product.errors.invalid?(:title) end p190 assert_match(pattern, string, message) assert_not_ ...
1.类级的变量 及 form.select 中 prompt 的作用 及 validates_inclusion_of 的用法 p 137 ruby 代码   form.select :pay_type, Order::PAYMENT_TYPES, :prompt => "select a payment method"      class Order < A ...
1. button_to 在客户端生成表单 用于POST 提交 用法同 link_to p 92 button_to "Add to Cart", :action => add_to_cart %> 2. 把session存进数据库 p 97 1) rake db:sessions:create 2) rake db:migrate 3) # environment.rb # 打开 config.action_controller.session_store = :active_record_store 4) rake db:sessions:clear 5) 尽量在 sess ...
open2ye
搜索本博客
我的相册
Ac44ad89-992f-34f7-973c-60b25a6ddc0c-thumb
action_auth
共 26 张
最近加入圈子
存档
最新评论