【问题标题】:Migrating app from Rails 2 to Rails3: map.redirect将应用程序从 Rails 2 迁移到 Rails3:map.redirect
【发布时间】:2010-12-13 14:44:03
【问题描述】:

我有一个为 Rails 2 编写的应用程序,我试图在 rails3 下运行,但在第一个障碍(路由表)上失败了。我目前拥有的是以下内容:

map.redirect ':shortened', :controller => 'items', :action => 'redirect', :conditions => {:method => :get}

map.shorten '', :controller => 'items', :action => 'shorten'

但我正在尝试为 rails3 '翻译'这个 - 是否有与上述相同的方法可以工作?

非常感谢。

【问题讨论】:

    标签: ruby-on-rails routes ruby-on-rails-3


    【解决方案1】:

    有关您的重定向路线,请参见此处:http://guides.rubyonrails.org/routing.html#redirection

    对于您的第二条路线,您只需执行match '/shorten/' => 'items#shorten'

    【讨论】:

    • 第二个,绝对正确,非常感谢 - 第一次破解,这看起来正确但不完全:match "/:shortened" => redirect(:conditions => " /#:method => :get}")
    • 我不是 100% 清楚您希望重定向做什么?试试看match '/shortened' => redirect('/items/redirect/'), :constraints => {:method => "get"}
    • 我认为奥斯汀就是这样,我认为迁移到 rails3 中的其他问题是它无法正常工作的原因 - 非常感谢
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2011-04-08
    • 1970-01-01
    • 2012-01-28
    • 1970-01-01
    • 1970-01-01
    • 2017-02-04
    相关资源
    最近更新 更多