skip to main
|
skip to sidebar
memo temp
2008年12月18日 星期四
Rescue from dispatching, layout mailer
Rescue from dispatching
人家這個sample 太好 不知道要講啥 XD
class ApplicationController < ActionController::Base
rescue_from ActionController::RoutingError, :with => :route_not_found
rescue_from ActionController::MethodNotAllowed, :with => :invalid_method
private
def route_not_found
render :text => 'What the fuck are you looking for ?', :status => :not_found
end
def invalid_method
message = "Now, did your mom tell you to #{request.request_method.to_s.upcase} that ?"
render :text => message, :status => :method_not_allowed
end
end
Mailer Layouts
default 他會找 layout 裡 加上 _mailer的, 像這邊就是會去找layouts/user_mailer.html.erb
class UserMailer < ActionMailer::Base
def registration(user)
subject "You've registered"
from "system@example.com"
end
end
當然也可以自己指定 layou
class UserMailer < ActionMailer::Base
layout 'email'
...
end
沒有留言:
張貼留言
較新的文章
較舊的文章
首頁
訂閱:
張貼留言 (Atom)
state chart
eb
關於我自己
Lake
檢視我的完整簡介
pie chart
網誌存檔
►
2010
(1)
►
11月
(1)
►
2009
(26)
►
1月
(26)
▼
2008
(26)
▼
12月
(26)
[HTML] IE 表單 Enter 的 Bug
ruby memo
rails default mode
deploy
Gem dependencies
liquid,dynamic content
All About Layouts
rails 2.2 extra, delegate,gem
each_with_object,inject
header, redirect_to , render js, polymorphic_path
Rescue from dispatching, layout mailer
Shallow Routes, Resources With Specific Actions
etag,last_modified,Get
rails, thread-safe
alias_method_chain
rails2.2 extra, dynamic finder
join,include
sql,DATE,group by
Block in views, concat, capture, content_for,yield...
memoizable,rails2.2
overwrite attr_writer,=
rails I18n sample
rails execute sql
jquery parse xml
google ajax library api
using jquery in rails,jquery, rails,form,reset,esc...
沒有留言:
張貼留言