Rails:创建RSS提要的最佳实践 - MIME检测与FeedsController

时间:2022-01-26 19:37:36

I need several RSS feeds in my app. They are in a way similar to existing actions but with less options (no will_paginate, no sorting, only the most recent 20 results). So for example I have one action which shows all items tagged "amazing" and I also need one feed which shows the latest items tagged "amazing".

我的应用程序中需要多个RSS源。它们与现有操作类似,但选项较少(没有will_paginate,没有排序,只有最近的20个结果)。例如,我有一个动作,显示标记为“惊人”的所有项目,我还需要一个显示标记为“惊人”的最新项目的动作。

My question: Is it better practice to create a FeedsController with a "tag" action (that's what I'm doing now, it seems more clean to me) OR use respond_to in the TagsController's "show" action to do the slightly different find and serve the rss template? With the latter approach I would have both in one action but it's less clean.

我的问题:创建一个带有“标签”动作的FeedsController是更好的做法(这就是我现在正在做的事情,对我来说似乎更干净)或者在TagsController的“show”动作中使用respond_to来做稍微不同的查找和服务rss模板?使用后一种方法,我会同时采取一种行动但不太干净。

What's your opinion?

你怎么看?

Thanks!

1 个解决方案

#1


I use the latter approach (respond_to) because it is cleaner IMHO. An RSS feed is just an alternative representation of the same resource. Use a named scope to encapulate the find differences.

我使用后一种方法(respond_to)因为它更清洁恕我直言。 RSS提要只是同一资源的替代表示。使用命名范围来封装查找差异。

#1


I use the latter approach (respond_to) because it is cleaner IMHO. An RSS feed is just an alternative representation of the same resource. Use a named scope to encapulate the find differences.

我使用后一种方法(respond_to)因为它更清洁恕我直言。 RSS提要只是同一资源的替代表示。使用命名范围来封装查找差异。