ubuntu, ror, jQuery, css, website memo
太嫩, 沒啥心得, 用來紀錄每天學的
2009年9月4日 星期五
rails , lib, module
<br />#lib/create_auth.rb<br />module CreateAuth<br /> def create_auth(target='')<br /> #...<br /> end<br />end<br /><br />#app/controllers/membercenter_controller.rb<br /> #to include create_auth<br /> include CreateAuth<br /><br /> if cellphone_code == create_auth(ucs.cellphone)<br /> #...<br />
<br />require "tempfile"<br /><br />module ExternalMailWriter<br /> def write_external_mail(dir, from_email, from_url, to, subject, content)<br /> t = Tempfile.new("email", dir)<br /> n = t.path<br /> t.close(true)<br /> <br /> t = File.new(n, "w")<br /> t.puts "From: \"GoYou\" <no-reply@iwakela.com>"<br /> t.puts "To: #{to}"<br /> t.puts "Subject: #{subject}"<br /> t.puts<br /> t.puts _("Message sent from %s") % from_url<br /> t.puts<br /> t.puts content<br /> t.puts<br /> t.close<br /> end<br /><br /><br />#app/controllers/message_controller.rb<br />require_dependency "external_mail_writer"<br />include ExternalMailWriter<br /><br />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)<br />
沒有留言:
張貼留言
較新的文章
較舊的文章
首頁
訂閱:
張貼留言 (Atom)
沒有留言:
張貼留言