Note that there are some explanatory texts on larger screens.

plurals
  1. PONested resource with Atom Feed Helper
    text
    copied!<p>I'm trying to use the <a href="http://github.com/rails/atom_feed_helper/tree/master" rel="nofollow noreferrer">Rails Atom Feed Helper</a> to generate a feed for a nested resource. My view template (index.atom.builder) is:</p> <pre><code>atom_feed(:schema_date =&gt; @favourites.first.created_at) do |feed| feed.title("Favourites for #{@user.login}") feed.updated(@favourites.first.created_at) @favourites.each do |favourite| feed.entry(favourite, :url =&gt; favourite.asset.external_ref) do |entry| entry.title(favourite.asset.external_ref) entry.content(image_tag(favourite.asset.location), :type =&gt; 'html') entry.author do |author| author.name(@user.login) end end end end </code></pre> <p>And I have the following routes:</p> <pre><code> map.namespace :public do |pub| pub.resources :users, :has_many =&gt; [ :favourites ] pub.resources :favourites pub.resources :assets, :only =&gt; [ :show ] end </code></pre> <p>Unfortunately the url is failing to generate for the feed.entry line:</p> <pre><code>feed.entry(favourite, :url =&gt; favourite.asset.external_ref) do |entry| </code></pre> <p>The error is "undefined method `favourite_url' for ActionView::Base".</p> <p>I've tried changing the feed.entry line to: </p> <pre><code>feed.entry([:public, favourite], :url =&gt; favourite.asset.external_ref) do |entry| </code></pre> <p>But this then returns the entry for an Array rather than a favourite! Someone had a similar problem <a href="https://rails.lighthouseapp.com/projects/8994/tickets/1093-atom-feed-helper-generates-wrong-ids" rel="nofollow noreferrer">here also</a>.</p> <p>I know that adding the line:</p> <pre><code>map.resource :favourites </code></pre> <p>to my routes.rb would 'fix' this problem but this resource is only available nested beneath the /public namespace.</p> <p>Has anyone had this problem before?</p> <p>Cheers Arfon</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload