I have the following action:
def show
@video = @commentable = @favoritable = Video.find_by_key(params[:key])
Video.increment_counter(:views_count, @video.id)
end
But right now if find_by_key
doesn't find a record, it throws a RuntimeError
(Called id for nil
).
So how can I get that action to throw a 404 if a record isn't found?
I'm running Rails 3.2.1.