refinery / refinerycms-news

News Plugin for Refinery CMS
http://www.refinerycms.com
MIT License
121 stars 120 forks source link

Use the show action for archive news crashes the application #147

Open szymon33 opened 10 years ago

szymon33 commented 10 years ago

We have published news and archived news (thanks for archive widget). Sometimes you need to read archived news too. But you can not use controller show action like: link_to item.title, refinery.news_item_path(item)

This will not work and also will crash the application.

In the controller, there is: def find_news_item @item = Item.published.translated.find(params[:id]) end Because of published scope find method will crash the app. Notice that find_by_id might not. Proposition of change: def find_news_item @item = Item.translated.find(params[:id]) end

You can not use any decorator for this case because of before_filter :find_news_item will be always called I had to override the whole controller to see one archived news.

Is there anather way, shorter way? If not then I can make a pull request but this is 1 line change.

ghoppe commented 10 years ago

I just ran into this issue as well, and I view this as a bug.

There is a method in the controller find_published_news_items which finds published news items for the index view. If the news archive view includes a link to the full archived news article, then those links should actually work without throwing a 404 or crashing the app. There's no reason to use the published scope in the find_news_item method.

If you don't make a pull request, I will. ;)