# Non-conventional actions and Atom feeds

**URL:** <https://www.ruby-forum.com/t/non-conventional-actions-and-atom-feeds/135228>\
**Category:** Rails\
**Created:** [April 19, 2008, 2:46pm UTC](https://www.ruby-forum.com/t/non-conventional-actions-and-atom-feeds/135228 "2008-04-19T14:46:09Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![evensoul](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/e/e9c0ed/32.png) [@evensoul](https://www.ruby-forum.com/u/evensoul)\
**Post date:** [April 19, 2008, 2:46pm UTC](https://www.ruby-forum.com/t/non-conventional-actions-and-atom-feeds/135228/1 "2008-04-19T14:46:09Z")

</div>

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
```

---

<div class="post-metadata">

**Author:** ![evensoul](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/e/e9c0ed/32.png) [@evensoul](https://www.ruby-forum.com/u/evensoul)\
**Post date:** [April 20, 2008, 3:16pm UTC](https://www.ruby-forum.com/t/non-conventional-actions-and-atom-feeds/135228/2 "2008-04-20T15:16:13Z")

</div>

Do your actions define a response for atom requests in a respond\_to  
block ?

Jan

---

<div class="post-metadata">

**Author:** ![evensoul](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/e/e9c0ed/32.png) [@evensoul](https://www.ruby-forum.com/u/evensoul)\
**Post date:** [April 20, 2008, 3:44pm UTC](https://www.ruby-forum.com/t/non-conventional-actions-and-atom-feeds/135228/3 "2008-04-20T15:44:28Z")

</div>

On Apr 20, 3:15 pm, Jan-Christian F. [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid)  
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

---

<div class="post-metadata">

**Author:** ![evensoul](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/e/e9c0ed/32.png) [@evensoul](https://www.ruby-forum.com/u/evensoul)\
**Post date:** [April 20, 2008, 5:31pm UTC](https://www.ruby-forum.com/t/non-conventional-actions-and-atom-feeds/135228/4 "2008-04-20T17:31:26Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![evensoul](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/e/e9c0ed/32.png) [@evensoul](https://www.ruby-forum.com/u/evensoul)\
**Post date:** [April 20, 2008, 7:35pm UTC](https://www.ruby-forum.com/t/non-conventional-actions-and-atom-feeds/135228/5 "2008-04-20T19:35:00Z")

</div>

On Apr 20, 5:31 pm, Jan-Christian F. [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid)  
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

```
