help@rskworld.in +91 93305 39277
RSK World
  • Home
  • Development
    • Web Development
    • Mobile Apps
    • Software
    • Games
    • Project
  • Technologies
    • Data Science
    • AI Development
    • Cloud Development
    • Blockchain
    • Cyber Security
    • Dev Tools
    • Testing Tools
  • About
  • Contact

Theme Settings

Color Scheme
Display Options
Font Size
100%
Back to Project
RSK World
ruby-todo-list
/
app
/
helpers
RSK World
ruby-todo-list
Ruby Todo List - Task Management with User Authentication + Categories + Search + File Attachments + Email Notifications + Rails MVC + Modern Web Interface + API Integration + Educational Design
helpers
  • application_helper.rb2.6 KB
  • categories_helper.rb2.3 KB
  • tasks_helper.rb2.5 KB
application_helper.rb
app/helpers/application_helper.rb
Raw Download
Find: Go to:
# Ruby To-Do List Application - Application Helper
# Created by: Molla Samser (help@rskworld.in, +91 93305 39277)
# Address: Nutanhat, Mongolkote, Purba Burdwan, West Bengal, India, 713147
# Year: 2026

module ApplicationHelper
  # Format datetime for display
  def format_datetime(datetime)
    datetime.strftime("%B %d, %Y at %I:%M %p") if datetime.present?
  end

  # Format date for display
  def format_date(date)
    date.strftime("%B %d, %Y") if date.present?
  end

  # Check if date is overdue
  def overdue?(date)
    date.present? && date < Date.current
  end

  # Check if date is due today
  def due_today?(date)
    date.present? && date == Date.current
  end

  # Get CSS classes for priority badges
  def priority_badge_classes(priority)
    base_classes = "badge"
    case priority
    when 1
      "#{base_classes} bg-success"
    when 2
      "#{base_classes} bg-warning text-dark"
    when 3
      "#{base_classes} bg-danger"
    else
      "#{base_classes} bg-secondary"
    end
  end

  # Get CSS classes for status badges
  def status_badge_classes(completed)
    completed ? "badge bg-success" : "badge bg-warning text-dark"
  end

  # Format file size
  def format_file_size(bytes)
    return "0 B" if bytes.zero?

    units = ['B', 'KB', 'MB', 'GB', 'TB']
    exponent = (Math.log(bytes) / Math.log(1024)).to_i
    exponent = units.length - 1 if exponent > units.length - 1

    "%.1f %s" % [bytes.to_f / (1024 ** exponent), units[exponent]]
  end

  # Generate random color for categories
  def random_category_color
    colors = ['#007bff', '#28a745', '#ffc107', '#dc3545', '#6f42c1', '#e83e8c', '#fd7e14', '#20c997']
    colors.sample
  end

  # Flash message classes for Bootstrap
  def flash_class(level)
    case level.to_sym
    when :notice, :success
      "alert alert-success alert-dismissible fade show"
    when :alert, :error
      "alert alert-danger alert-dismissible fade show"
    when :warning
      "alert alert-warning alert-dismissible fade show"
    when :info
      "alert alert-info alert-dismissible fade show"
    else
      "alert alert-secondary alert-dismissible fade show"
    end
  end

  # Active link helper
  def nav_link(text, path, options = {})
    classes = options[:class] || ""
    classes += " active" if current_page?(path)
    link_to text, path, class: classes.strip
  end

  # Loading spinner
  def loading_spinner(size = 'sm')
    content_tag :div, class: "spinner-border spinner-border-#{size}", role: "status" do
      content_tag :span, "Loading...", class: "visually-hidden"
    end
  end
end
93 lines•2.6 KB
ruby

About RSK World

Founded by Molla Samser, with Designer & Tester Rima Khatun, RSK World is your one-stop destination for free programming resources, source code, and development tools.

Founder: Molla Samser
Designer & Tester: Rima Khatun

Development

  • Game Development
  • Web Development
  • Mobile Development
  • AI Development
  • Development Tools

Legal

  • Terms & Conditions
  • Privacy Policy
  • Disclaimer

Contact Info

Nutanhat, Mongolkote
Purba Burdwan, West Bengal
India, 713147

+91 93305 39277

hello@rskworld.in
support@rskworld.in

© 2026 RSK World. All rights reserved.

Content used for educational purposes only. View Disclaimer