ubuntu, ror, jQuery, css, website memo
太嫩, 沒啥心得, 用來紀錄每天學的
2009年9月4日 星期五
rails , lib, module
#lib/create_auth.rb
module CreateAuth
def create_auth(target='')
#...
end
end
#app/controllers/membercenter_controller.rb
#to include create_auth
include CreateAuth
if cellphone_code == create_auth(ucs.cellphone)
#...
require "tempfile"
module ExternalMailWriter
def write_external_mail(dir, from_email, from_url, to, subject, content)
t = Tempfile.new("email", dir)
n = t.path
t.close(true)
t = File.new(n, "w")
t.puts "From: \"GoYou\"
"
t.puts "To: #{to}"
t.puts "Subject: #{subject}"
t.puts
t.puts _("Message sent from %s") % from_url
t.puts
t.puts content
t.puts
t.close
end
#app/controllers/message_controller.rb
require_dependency "external_mail_writer"
include ExternalMailWriter
write_external_mail(EXTERNAL_MAIL_PATH, EXTERNAL_MAIL_SENDER, @msg.from_user.shortname + " " + url_for(:controller => "user", :action => "show", :id => @me.id, :only_path => false) , email, @msg.subject, @msg.body)
沒有留言:
張貼留言
較新的文章
較舊的文章
首頁
訂閱:
張貼留言 (Atom)
沒有留言:
張貼留言