6.4. Other Action Controller Changes
HTTP Accept header 現在default 是 disable 啦, 想要打開要自己開
不然就是自己在生時後面要有type啦 像 url /customers/1.xml
redirect_to now fully supports URI schemes (so, for example, you can redirect to a svn+ssh: URI).
有js 參數可以用不用在自己設response.headers['Content-Type']='text/javascript'
render now supports a :js option to render plain vanilla javascript with the right mime type.
Polymorphic URLs behave more sensibly if a passed parameter is nil. For example, calling polymorphic_path([@project, @date, @area]) with a nil date will give you project_area_path
2008年12月18日 星期四
header, redirect_to , render js, polymorphic_path
6.4. Other Action Controller Changes
HTTP Accept header 現在default 是 disable 啦, 想要打開要自己開
不然就是自己在生時後面要有type啦 像 url /customers/1.xml
redirect_to now fully supports URI schemes (so, for example, you can redirect to a svn+ssh: URI).
有js 參數可以用不用在自己設response.headers['Content-Type']='text/javascript'
render now supports a :js option to render plain vanilla javascript with the right mime type.
Polymorphic URLs behave more sensibly if a passed parameter is nil. For example, calling polymorphic_path([@project, @date, @area]) with a nil date will give you project_area_path
HTTP Accept header 現在default 是 disable 啦, 想要打開要自己開
不然就是自己在生時後面要有type啦 像 url /customers/1.xml
redirect_to now fully supports URI schemes (so, for example, you can redirect to a svn+ssh: URI).
有js 參數可以用不用在自己設response.headers['Content-Type']='text/javascript'
render now supports a :js option to render plain vanilla javascript with the right mime type.
Polymorphic URLs behave more sensibly if a passed parameter is nil. For example, calling polymorphic_path([@project, @date, @area]) with a nil date will give you project_area_path
2008年9月7日 星期日
redirect_to
http://api.rubyonrails.org/classes/ActionController/Base.html#M000852
http://en.wikipedia.org/wiki/List_of_HTTP_status_codes
http://en.wikipedia.org/wiki/List_of_HTTP_status_codes
redirect_to post
redirect_to :action => "show", :id => 5
redirect_to "http://www.rubyonrails.org"
redirect_to "/images/screenshot.jpg"
redirect_to articles_url
redirect_to :backThe redirection happens as a "302 Moved" header unless otherwise specified.
Examples:
redirect_to post_url(@post), :status=>:found
redirect_to :action=>'atom', :status=>:moved_permanently
redirect_to post_url(@post), :status=>301
redirect_to :action=>'atom', :status=>302
:back - Back to the page that issued the request. Useful for forms that are triggered from multiple places. Short-hand for redirect_to(request.env["HTTP_REFERER"])
- 301 Moved Permanently
- This and all future requests should be directed to the given URI.
- 302 Found
- This is the most popular redirect code, but also an example of industrial practice contradicting the standard. HTTP/1.0 specification (RFC 1945) required the client to perform a temporary redirect (the original describing phrase was "Moved Temporarily"), but popular browsers implemented it as a 303 See Other. Therefore, HTTP/1.1 added status codes 303 and 307 to disambiguate between the two behaviours. However, the majority of Web applications and frameworks still use the 302 status code as if it were the 303.
- The response to the request can be found under another URI using a GET method.
- In this occasion, the request should be repeated with another URI, but future requests can still use the original URI. In contrast to 303, the request method should not be changed when reissuing the original request. For instance, a POST request must be repeated using another POST request.
標籤:
redirect_to
訂閱:
文章 (Atom)