Method: ApplicationHelper#generic_show_link

Defined in:
app/helpers/application_helper.rb

Get a link to the specified post. Also works for help and policy documents.

Parameters:

  • post (Post)

    The post to link to.

Returns:

  • (String)


196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
# File 'app/helpers/application_helper.rb', line 196

def generic_show_link(post)
  if top_level_post_types.include? post.post_type_id
    post_url(post)
  elsif second_level_post_types.include?(post.post_type_id)
    post_url(post.parent, anchor: "answer-#{post.id}")
  else
    case post.post_type_id
    when HelpDoc.post_type_id
      help_url(post.doc_slug)
    when PolicyDoc.post_type_id
      policy_url(post.doc_slug)
    else
      '#'
    end
  end
end