Sha256: 7c452d8fa7d10b3a28260867501b23fa3cf4d7ac99b7c550891b50c781454fff
Contents?: true
Size: 1.21 KB
Versions: 6
Compression:
Stored size: 1.21 KB
Contents
module UserHelper DEFAULT_HEAD_OPTIONS = { :notice => true, :message => true, :error => false }.freeze unless defined? DEFAULT_HEAD_OPTIONS def title_helper "#{controller.controller_class_name} #{controller.action_name}" end 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 def start_form_tag_helper(options = {}) url = url_for(:action => "#{controller.action_name}") "#{self.send(:form_tag, url, options)}" end def user_id session[:user_id] end def user? !user_id.nil? end def user User.find(user_id) end end
Version data entries
6 entries across 6 versions & 1 rubygems