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
- #head_helper(label, options = {}) ⇒ Object
- #start_form_tag_helper(options = {}) ⇒ Object
- #title_helper ⇒ Object
- #user ⇒ Object
- #user? ⇒ Boolean
- #user_id ⇒ Object
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, = {}) notice = = error = nil opts = DEFAULT_HEAD_OPTIONS.dup opts.update(.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] = "<div id=\"ErrorExplanation\"><p>#{flash['message']}</p></div>" s = s + end if not opts[:error].nil? and opts[:error] error = ('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( = {}) url = url_for(:action => "#{controller.action_name}") "#{self.send(:form_tag, url, )}" end |
#title_helper ⇒ Object
9 10 11 |
# File 'app/helpers/user_helper.rb', line 9 def title_helper "#{controller.controller_class_name} #{controller.action_name}" end |
#user ⇒ Object
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
45 46 47 |
# File 'app/helpers/user_helper.rb', line 45 def user? not user.nil? end |
#user_id ⇒ Object
41 42 43 |
# File 'app/helpers/user_helper.rb', line 41 def user_id session[:user_id] end |