Module: UserHelper

Defined in:
app/helpers/user_helper.rb

Constant Summary collapse

DEFAULT_HEAD_OPTIONS =
{
  :notice => true,
  :message => true,
  :error => false
}.freeze

Instance Method Summary collapse

Instance Method Details

#head_helper(label, options = {}) ⇒ Object



13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
# File 'app/helpers/user_helper.rb', line 13

def head_helper(label, options = {})
  notice = message = error = nil
  opts = DEFAULT_HEAD_OPTIONS.dup
  opts.update(options.symbolize_keys)
  s = "<h3>#{label}</h3>"
  if flash['notice'] and not opts[:notice].nil? and opts[:notice]
    notice = "<div><p>#{flash['notice']}</p></div>"
    s = s + notice
  end
  if flash['message'] and not opts[:message].nil? and opts[:message]
    message = "<div id=\"ErrorExplanation\"><p>#{flash['message']}</p></div>"
    s = s + message
  end
  if not opts[:error].nil? and opts[:error]
   error = error_messages_for('user')
   if not error.nil?
     error = error + "<br/>"
     s = s + error
   end
 end
 return s
end

#start_form_tag_helper(options = {}) ⇒ Object



36
37
38
39
# File 'app/helpers/user_helper.rb', line 36

def start_form_tag_helper(options = {})
  url = url_for(:action => "#{controller.action_name}")
  "#{self.send(:form_tag, url, options)}"
end

#title_helperObject



9
10
11
# File 'app/helpers/user_helper.rb', line 9

def title_helper
  "#{controller.controller_class_name} #{controller.action_name}"
end

#userObject



49
50
51
# File 'app/helpers/user_helper.rb', line 49

def user
  User.find_by_id(user_id) if user_id
end

#user?Boolean

Returns:

  • (Boolean)


45
46
47
# File 'app/helpers/user_helper.rb', line 45

def user?
  not user.nil?
end

#user_idObject



41
42
43
# File 'app/helpers/user_helper.rb', line 41

def user_id
  session[:user_id]
end