public
Rubygem
Description: Merb Core: All you need. None you don't.
Homepage: http://www.merbivore.com
Clone URL: git://github.com/wycats/merb-core.git
Search Repo:
Added option to Controller#redirect(url, permanent) so 301 responses can 
be returned as well
fabien (author)
Sat May 10 07:53:38 -0700 2008
commit  301aa82c8d54b6bc84f9531baef901b525124d81
tree    fb3377a1600e14fbf646e13261d24d152e1f56de
parent  3067468bbee7d877e633a8e51999b0fd15065a9d
...
92
93
94
 
 
95
96
97
...
99
100
101
102
103
104
 
 
 
 
105
106
107
...
92
93
94
95
96
97
98
99
...
101
102
103
 
 
 
104
105
106
107
108
109
110
0
@@ -92,6 +92,8 @@
0
     # ==== Parameters
0
     # url<String>::
0
     # URL to redirect to. It can be either a relative or fully-qualified URL.
0
+ # permanent<Boolean>::
0
+ # When true, return status 301 Moved Permanently
0
     #
0
     # ==== Returns
0
     # String:: Explanation of redirect.
0
@@ -99,9 +101,10 @@
0
     # ==== Examples
0
     # redirect("/posts/34")
0
     # redirect("http://www.merbivore.com/")
0
- def redirect(url)
0
- Merb.logger.info("Redirecting to: #{url}")
0
- self.status = 302
0
+ # redirect("http://www.merbivore.com/")
0
+ def redirect(url, permanent = false)
0
+ self.status = permanent ? 301 : 302
0
+ Merb.logger.info("Redirecting to: #{url} (#{self.status})")
0
       headers['Location'] = url
0
       "<html><body>You are being <a href=\"#{url}\">redirected</a>.</body></html>"
0
     end

Comments

  • ivey Sat May 10 22:29:39 -0700 2008

    I would have sworn we did this already. I’m glad we have it now.