Non-conventional actions and Atom feeds

I would like to provide Atom feeds in response to different actions.
I am aware that eg map.resources :posts helps me generate a feed
as a request for /posts.:format, but as I am getting into problems,
I see that I do not have the full understanding of what is going on.

I would like to do the same (but with a different dataset) for other
actions such as /posts/today or /posts/yesterday.

For instance, I have created app/views/posts/today.atom.builder file,

and in today.html.erb view I put
<%= auto_discovery_link_tag :atom, url_for(:action => ‘today’) %>

but clicking on the feed icon in Firefox only reloads the html page,
while explicitly requesting posts/today.atom produces:

ActionController::RoutingError (No route matches “/pots/today.atom”
with {:method=>:get})

What am I missing? Should I specify a new named route?

Marko

Do your actions define a response for atom requests in a respond_to
block ?

Jan

On Apr 20, 3:15 pm, Jan-Christian F. [email protected]
wrote:

Do your actions define a response for atom requests in a respond_to
block ?

Currently it looks like:

def today
# load @posts
respond_to do |format|
format.html
format.atom
end
end

Marko

Have you included your additional methods in your routes.rb, as in

map.resources :posts, :collection => { :today => :get, :yesterday
=> :get }

? That should do the trick.

Also, I think the url_for you’re using in auto_discovery_link_tag
lacks the format parameter; I think you can use

formatted_today_posts_url(:atom)

and

formatted_yesterday_posts_url(:atom)

instead.

On Apr 20, 5:31 pm, Jan-Christian F. [email protected]
wrote:

formatted_today_posts_url(:atom)

and

formatted_yesterday_posts_url(:atom)

instead.

Thank you, the :collections parameter to map.resources is
what it takes. And it gives the formatted_* helpers.
Now the API docs are more clear :).

Marko

This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.

| Privacy Policy | Terms of Service | Remote Ruby Jobs