1

I have the following nested resource:

resources :categories, :only => [:show], :path => "" do
resources :games, :only => [:show], :path => "" do
end

To retrieve all items i do:

 @feeditems = Game.all(:include => [:categorygames => :category])

To show them in an .erb template:

<%= category_game_path(feeditem.categorygames.first.category, feeditem) %>

This works fine so far. Now i wanted to use the same way to include the url in a atom feed. I have to specify the url, so i did the following:

@feeditems.each do |feeditem|
feed.entry(feeditem, :url => category_game_path(feeditem.categorygames.first.category, feeditem)) do |entry|
  entry.title feeditem.name_de
...

Unfortunately i always get a "NoMethodError"-Error, and "undefined method `category_game__path' #<#:0x007fa7c96c3090>"

Why does builder behaves different to a .erb-template? Any idea, how can sort this out?

EDIT

I got one step further, since someone else had a similar problem.

I changed it to this:

 feed.entry(:url => url_for(:action => 'show', :controller =>'games', :category_id => feeditem.categorygames.first.category, :id => feeditem, :only_path => false)) do |entry|

Now i get this error:

     undefined method `id' for {:url=>"http://localhost:3000/sport-games/wizard-game"}:Hash 

Still, i do not have an idea so solve this.

4

1 回答 1

1

我不知道为什么,但在重新启动服务器和冷重新加载后,它是这样工作的:

feed.entry(feeditem, :url => url_for(:action =>'show', :controller =>'games',:category_id => feeditem.categorygames.first.category, :id => feeditem, :only_path => false)) do |entry|
于 2013-07-23T13:06:08.127 回答