我想弄清楚如何正確設置rack-rewrite並且遇到了一些麻煩。我是一個小菜鳥,該網站並沒有超清晰的設置。如果有人對此有更多的瞭解,我有幾個問題。適用於本地dev和heroku的獨角獸機架重寫適當的配置
1)我是否需要將寶石放在我的gemfile
和config.ru
文件中? (根據自述文件部分中的「Sample rackup file」)
2)我是否需要在我的config.ru
文件和我的config/application.rb
文件中都有機架重寫設置? (根據自述文件中的「示例rackup文件」和「Rails應用程序中的示例用法」部分)
3)在我的application.rb
文件中,我將配置?在class Application < Rails::Application
區塊?
4)我已經嘗試了上面的兩個,但是,當我開始unicorn
本地,我收到以下錯誤
$ unicorn
I, [2014-05-13T16:57:00.926144 #17432] INFO -- : Refreshing Gem list
/config/environment.rb:2:in `require': /config/application.rb:98: syntax error, unexpected end-of-input, expecting keyword_end (SyntaxError)
from /config/environment.rb:2:in `<top (required)>'
from config.ru:4:in `require'
from config.ru:4:in `block in <main>'
from /Users/me/.rvm/gems/[email protected]/gems/rack-1.4.5/lib/rack/builder.rb:51:in `instance_eval'
from /Users/me/.rvm/gems/[email protected]/gems/rack-1.4.5/lib/rack/builder.rb:51:in `initialize'
from config.ru:1:in `new'
from config.ru:1:in `<main>'
from /Users/me/.rvm/gems/[email protected]/gems/unicorn-4.8.2/lib/unicorn.rb:48:in `eval'
from /Users/me/.rvm/gems/[email protected]/gems/unicorn-4.8.2/lib/unicorn.rb:48:in `block in builder'
from /Users/me/.rvm/gems/[email protected]/gems/unicorn-4.8.2/lib/unicorn/http_server.rb:760:in `call'
from /Users/me/.rvm/gems/[email protected]/gems/unicorn-4.8.2/lib/unicorn/http_server.rb:760:in `build_app!'
from /Users/me/.rvm/gems/[email protected]/gems/unicorn-4.8.2/lib/unicorn/http_server.rb:137:in `start'
from /Users/me/.rvm/gems/[email protected]/gems/unicorn-4.8.2/bin/unicorn:126:in `<top (required)>'
from /Users/me/.rvm/gems/[email protected]/bin/unicorn:23:in `load'
from /Users/me/.rvm/gems/[email protected]/bin/unicorn:23:in `<main>'
from /Users/me/.rvm/gems/[email protected]/bin/ruby_noexec_wrapper:14:in `eval'
from /Users/me/.rvm/gems/[email protected]/bin/ruby_noexec_wrapper:14:in `<main>'>'
--------------- -----更新--------------------
我已經解決了上述問題。看起來這個寶石非常多才多藝,你可以在application.rb
,config.ru
中設置它,或者在初始化程序目錄中創建一個rack_rewrite.rb
文件。
有沒有人有任何意見,最好的地方是把代碼放在哪裏?
另外,有沒有一種方法來解決重定向中尾隨/
?比如說,有沒有辦法將它壓縮成一行?
r301 '/for-gyms-and-rec-centers', '/venues/3'
r301 '/for-gyms-and-rec-centers/', '/venues/3/