Skip to content

Instantly share code, notes, and snippets.

@almaron
Created June 15, 2012 13:48
Show Gist options
  • Save almaron/2936556 to your computer and use it in GitHub Desktop.
Save almaron/2936556 to your computer and use it in GitHub Desktop.
A bug while displaying associated records.
#Forum model
has_many :topics
#Topic model
belongs_to :forum
#forums#show action
def show
@forum = Forum::Forum.find_by_id(params[:id])
if @forum.hidden > 0 && !(user_in?([:admins, :masters]) || user_permitted?(:show_hidden))
url = case @forum.parent_id
when 0 then forums_path
else forum_path(@forum.parent)
end
redirect_to url
else
@topics = @forum.topics
@meta[:title] = "#{@forum.name} - #{t("forum.head.index")}"
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment