Module: Thredded::ApplicationHelper

Defined in:
app/helpers/thredded/application_helper.rb

Instance Method Summary collapse

Instance Method Details

#edit_post_path(post) ⇒ Object



33
34
35
36
37
38
39
# File 'app/helpers/thredded/application_helper.rb', line 33

def edit_post_path(post)
  if post.private_topic_post?
    edit_private_topic_private_post_path(post.postable, post)
  else
    edit_messageboard_topic_post_path(messageboard, post.postable, post)
  end
end

#paginate(collection, args = {}) ⇒ Object



29
30
31
# File 'app/helpers/thredded/application_helper.rb', line 29

def paginate(collection, args = {})
  super(collection, args.reverse_merge(views_prefix: 'thredded'))
end

#thredded_page(&block) ⇒ Object

Render the page container with the supplied block as content.



4
5
6
7
8
9
# File 'app/helpers/thredded/application_helper.rb', line 4

def thredded_page(&block)
  # enable the host app to easily check whether a thredded view is being rendered:
  content_for :thredded, true
  content_for :thredded_page_content, &block
  render partial: 'thredded/shared/page'
end

#time_ago(datetime) ⇒ String

Returns html_safe datetime presentation.

Parameters:

Returns:

  • html_safe datetime presentation



25
26
27
# File 'app/helpers/thredded/application_helper.rb', line 25

def time_ago(datetime)
  render partial: 'thredded/shared/time_ago', locals: { datetime: datetime }
end

Returns html_safe link to the user.

Parameters:

Returns:

  • html_safe link to the user



19
20
21
# File 'app/helpers/thredded/application_helper.rb', line 19

def user_link(user)
  render partial: 'thredded/users/link', locals: { user: user }
end

#user_path(user) ⇒ String

Returns path to the user as specified by Thredded.user_path.

Parameters:

Returns:



13
14
15
# File 'app/helpers/thredded/application_helper.rb', line 13

def user_path(user)
  Thredded.user_path(self, user)
end