【问题标题】:Rails 2 route unknown to me when porting app to Rails 3将应用程序移植到 Rails 3 时,我不知道 Rails 2 的路线
【发布时间】:2012-06-04 02:19:54
【问题描述】:

我似乎无法弄清楚如何将这条特定路线从 Rails 2 移植到 3:

map.resources :webservices, :new => { :push_data => :post, :reset_url => :post }

相关的馅饼在这里:http://pastie.org/4022761

【问题讨论】:

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


    【解决方案1】:

    好的,我明白你要做什么了。
    您需要像这样更新您的 routes.rb 文件:

    resources :webservices do 
        post :push_data, :on => :new
        post :reset_url, :on => :new
    end
    

    我对我在一个名为 Notes 的项目中的模型做了这个,当我调用 rake 路由时,它给了我这个:

    push_data_new_note POST   /notes/new/push_data(.:format)        notes#push_data
    reset_url_new_note POST   /notes/new/reset_url(.:format)        notes#reset_url
    new_note           GET    /notes/new(.:format)                  notes#new
    

    这应该可以解决您遇到的路线问题。让我知道你的效果如何。

    【讨论】:

    • @PedroNascimento 没问题。很高兴我能提供帮助。
    猜你喜欢
    • 2012-08-06
    • 2011-12-09
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2015-01-13
    相关资源
    最近更新 更多