摘要:
最近用到发送邮件的功能,没办法只能现学,天生愚钝啊,用了两天才弄明白了。。记录一下 --------------------------------------------------- 在models 里边新建一个mailer 模型 class Notifier < ActionMailer::Base def send_mail(params = {}) ... 阅读全文
摘要:
搜索结果的分页显示是一个常用功能,实现方式有很多中,rails也内建了对分页的支持,但是rails2.0将去掉分页组件,将分页功能交给plugin去实现,这里通过一个简单的例子展示如何使用最流行的rails分页plugin -- will_paginate. 1.安装will_paginate,编写分页代码 安装: ruby script\plugin install svn://errt... 阅读全文
摘要:
ruby的Kernal.sprintf()可以实现保留两位小数的方法,format是sprintf的alias。 format(“pattern”, value):其中pattern表示要格式化形式,在这里我们用“%.2f”,表示保留小数点后2位数字,当然我们还可以写成“%05.2f”,表示整个字符串最少5位数(不包括小数点),如果value少于5位用”0”占位。 sprintf("%... 阅读全文
摘要:
第一种: Ror代码 class FooController < ApplicationController protect_from_forgery :except => :index # you can disable csrf protection on controller-by-controller basis: skip_before_fil... 阅读全文