代码之家  ›  专栏  ›  技术社区  ›  Kirschstein

为什么url不是我认为应该呈现的那样?

  •  0
  • Kirschstein  · 技术社区  · 15 年前

    @statics = [{'home' => 'about'},
                {'home' => 'termsandconditions'},
                {'home' => 'information'},
                {'news' => 'archives'}]
    

    在我看来:

    @statics.each do |controller, action|
      xml.loc url_for(:only_path => false, :controller => controller, :action => action)
      xml.lastmod     w3c_date(Time.now)
      xml.changefreq  "weekly"
      xml.priority    0.8
    end
    

    http://localhost:3000/homeinformation
    

    而不是

    http://localhost:3000/information
    

    url_for(:only_path => false, :controller => 'brownies', :action => 'index') #works!
    

    我错过了什么?

    1 回复  |  直到 15 年前
        1
  •  0
  •   Chowlett    15 年前

    @statics 是一个具有一个哈希项的数组,因此您需要 each