Sha256: 4b66f7b9a37a578d8bcf41d669130b9ca76106f7a8a7d8f8dd2c84e8429c46c8

Contents?: true

Size: 1.23 KB

Versions: 74

Compression:

Stored size: 1.23 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?
    not user.nil?
  end
  
  def user
    User.find_by_id(user_id) if user_id
  end

end

Version data entries

74 entries across 74 versions & 1 rubygems

Version Path
backlog-0.1.1 app/helpers/user_helper.rb
backlog-0.1.2 app/helpers/user_helper.rb
backlog-0.10.0 app/helpers/user_helper.rb
backlog-0.10.1 app/helpers/user_helper.rb
backlog-0.10.4 app/helpers/user_helper.rb
backlog-0.10.2 app/helpers/user_helper.rb
backlog-0.10.3 app/helpers/user_helper.rb
backlog-0.10.5 app/helpers/user_helper.rb
backlog-0.10.6 app/helpers/user_helper.rb
backlog-0.10.7 app/helpers/user_helper.rb
backlog-0.11.0 app/helpers/user_helper.rb
backlog-0.10.8 app/helpers/user_helper.rb
backlog-0.12.0 app/helpers/user_helper.rb
backlog-0.12.1 app/helpers/user_helper.rb
backlog-0.12.2 app/helpers/user_helper.rb
backlog-0.12.3 app/helpers/user_helper.rb
backlog-0.12.4 app/helpers/user_helper.rb
backlog-0.13.0 app/helpers/user_helper.rb
backlog-0.13.1 app/helpers/user_helper.rb
backlog-0.14.0 app/helpers/user_helper.rb