2010-10-11 33 views
0

我有这个在我的控制器:为什么不是url_for渲染这个像我认为它应该?

@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! 

缺少什么我在这里?

回答

0

@statics是一个带有一个散列项的数组,因此您需要您的each块只取一个参数并在块内分割它。

+0

啊,欢呼声。我需要的是一组数组。错误地使用哈希... – Kirschstein 2010-10-11 21:08:02

相关问题