Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
szymon33 opened this issue Feb 6, 2014 · 1 comment
Open

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

szymon33 opened this issue Feb 6, 2014 · 1 comment

Comments

@szymon33
Copy link

szymon33 commented Feb 6, 2014

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
Copy link

ghoppe commented Jun 17, 2014

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. ;)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants