1.类级的变量 及 form.select 中 prompt 的作用 及 validates_inclusion_of 的用法
p 137
prompt 空的选择的提示
2.保存未登录用户访问的 uri 在他登录后自动转向
p 159
3.link_to 可以加 method => "post"
4.删除的事务 这样做后可以自动回滚
def after_destroy
if User.count.zero?
raise "Can't delete last user."
end
end
5. logger.info(" ..info .. ")
6.use curl test REST
> curl -H "Accept: application/xml" http://localhost:3000/info/who_bought/1
> curl -H "Accept: text/html" http://localhost:3000/info/who_bought/1
7.render :xml => @product.to_xml(:include => :orders)
8.
# HTML 模式文档
rake doc:app
# code stats
rake stats
p 137
ruby 代码
- form.select :pay_type, Order::PAYMENT_TYPES, :prompt => "select a payment method"
- class Order < ActiveRecord::Base
- validates_inclusion_of :pay_type, :in => PAYMENT_TYPES.map { | disp, value| value}
- PAYMENT_TYPES = [
- # Displayed stored in db
- ["Check", "check"],
- ["credit card", "cc"],
- ["purchase order "]
- ]
prompt 空的选择的提示
2.保存未登录用户访问的 uri 在他登录后自动转向
p 159
ruby 代码
- session[:original_uri] = request.request_uri
- uri = session[:original_uri]
- session[:original_uri] = nil
- redirect_to(uri || {:action => "index" })
3.link_to 可以加 method => "post"
4.删除的事务 这样做后可以自动回滚
def after_destroy
if User.count.zero?
raise "Can't delete last user."
end
end
5. logger.info(" ..info .. ")
6.use curl test REST
> curl -H "Accept: application/xml" http://localhost:3000/info/who_bought/1
> curl -H "Accept: text/html" http://localhost:3000/info/who_bought/1
7.render :xml => @product.to_xml(:include => :orders)
xml 代码
- <product>
- <name>new_productname>
- <orders>
- <order>
- <id>100id>
- <price>200price>
- <order>
- <order>
- <id>101id>
- <price>202price>
- <order>
- orders>
- product>
8.
# HTML 模式文档
rake doc:app
# code stats
rake stats
发表评论
- 浏览: 9585 次
- 性别:

- 来自: 温州

- 详细资料
搜索本博客
我的相册
action_auth
共 26 张
共 26 张
最近加入圈子
链接
最新评论
-
ruby 又一BUG 折磨了我很 ...
放这里记一下sudo apt-get install openssh-clien ...
-- by open2ye -
rails 的测试的 bug 当你 ...
还有一个可能造成这个问题的原因是rails test的transactional ...
-- by iamawalrus -
rails 的测试的 bug 当你 ...
gigix 写道 干嘛不放在before_save呢? 例如Part 在 be ...
-- by open2ye -
rails 的测试的 bug 当你 ...
iamawalrus 写道 检查test环境的db以及对应的table是否和de ...
-- by open2ye -
rails 的测试的 bug 当你 ...
open2ye 写道这个需求很普遍 比如一个是零件表, 另一个是零件的创建日志 ...
-- by iamawalrus






评论排行榜