Module: ContactsHelper

Defined in:
app/helpers/contacts_helper.rb

Instance Method Summary collapse

Instance Method Details

#anonymous_contact_buttonObject



38
39
40
41
42
43
44
45
46
# File 'app/helpers/contacts_helper.rb', line 38

def anonymous_contact_button
  if SocialStream.relation_model == :follow
    form_tag new_user_session_path do |f|
      submit_tag t('contact.follow')
    end
  else
    link_to t("contact.new.link"), new_user_session_path
  end
end

#contact_button(contact_or_actor) ⇒ Object

Add contact button



11
12
13
14
15
16
17
# File 'app/helpers/contacts_helper.rb', line 11

def contact_button(contact_or_actor)
  if user_signed_in?
    current_actor_contact_button contact_or_actor
  else
    anonymous_contact_button
  end
end

#contact_count(actor) ⇒ Object



2
3
4
5
6
7
8
# File 'app/helpers/contacts_helper.rb', line 2

def contact_count(actor)
  if user_signed_in?
    t 'contact.in_common', :count => current_subject.common_contacts_count(actor)
  else
    t 'contact.n', count: actor.sent_active_contact_count
  end
end

#current_actor_contact_button(contact_or_actor) ⇒ Object



19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
# File 'app/helpers/contacts_helper.rb', line 19

def current_actor_contact_button contact_or_actor
  c =
    if contact_or_actor.is_a?(Contact)
      if contact_or_actor.sender == current_actor
        contact_or_actor
      else
        current_actor.contact_to!(contact_or_actor.receiver)
      end
    else
      current_actor.contact_to!(contact_or_actor)
    end

  if c.reflexive?
    t('subject.this_is_you')
  else
    render :partial => "contacts/link_#{ SocialStream.relation_model }", :locals => { :contact => c }
  end
end

#current_contact_section?(section) ⇒ Boolean

Returns:

  • (Boolean)


48
49
50
# File 'app/helpers/contacts_helper.rb', line 48

def current_contact_section? section
  params[:type] == section.to_s
end