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
  • Blog
  • About
  • Contact

Theme Settings

Color Scheme
Display Options
Font Size
100%
Back to Project
RSK World
ruby-calculator
/
app
/
models
RSK World
ruby-calculator
Ruby Calculator Pro - Interactive Calculator with 8 Types + Mathematical Functions + Rails MVC + Modern Web Interface + API Integration + Educational Design
models
  • calculation_history.rb743 B
  • converter.rb5.2 KB
  • equation_solver.rb7.1 KB
  • favorite_calculation.rb1.5 KB
  • financial_calculator.rb7.7 KB
  • graph_calculator.rb4 KB
  • health_calculator.rb7.4 KB
  • programming_calculator.rb5.6 KB
  • theme.rb4.8 KB
.gitignorefavorite_calculation.rb
.gitignore
Raw Download
Find: Go to:
# Ruby Calculator - Interactive calculator built with Ruby on Rails
# Author: RSK World (Molla Samser, Founder | Rima Khatun, Designer & Tester)
# Contact: help@rskworld.in | +91 93305 39277
# Website: https://rskworld.in
# Year: 2026
# Description: Build a fully functional calculator using Ruby on Rails with modern UI

# See https://help.github.com/articles/ignoring-files for more about ignoring files.
#
# If you find yourself ignoring temporary files generated by your text editor
# or operating system, you probably want to add a global ignore instead:
#   git config --global core.excludesfile '~/.gitignore_global'

# Ignore bundler config.
/.bundle

# Ignore the default SQLite database.
/db/*.sqlite3
/db/*.sqlite3-*

# Ignore all logfiles and tempfiles.
/log/*
/tmp/*
!/log/.keep
!/tmp/.keep

# Ignore pidfiles, but keep the directory.
/tmp/pids/*
!/tmp/pids/
!/tmp/pids/.keep

# Ignore uploaded files in development.
/storage/*
!/storage/.keep

/public/assets
.byebug_history

# Ignore master key for decrypting credentials and more.
/config/master.key

/public/packs
/public/packs-test
/node_modules
/yarn-error.log
yarn-debug.log*
.yarn-integrity

# Ignore .env files
.env
.env.local
.env.development.local
.env.test.local
.env.production.local

# Ignore IDE files
.vscode/
.idea/
*.swp
*.swo
*~

# Ignore OS generated files
.DS_Store
.DS_Store?
._*
.Spotlight-V100
.Trashes
ehthumbs.db
Thumbs.db

# Ignore Spring files.
/spring/tmp/
/spring/log/

# Ignore Rails assets pipeline
/app/assets/builds/*
!/app/assets/builds/.keep
79 lines•1.6 KB
text
app/models/favorite_calculation.rb
Raw Download
Find: Go to:
# Ruby Calculator - Interactive calculator built with Ruby on Rails
# Author: RSK World (Molla Samser, Founder | Rima Khatun, Designer & Tester)
# Contact: help@rskworld.in | +91 93305 39277
# Website: https://rskworld.in
# Year: 2026
# Description: Build a fully functional calculator using Ruby on Rails with modern UI

class FavoriteCalculation < ApplicationRecord
  belongs_to :calculation_history, optional: true
  
  validates :name, presence: true, length: { minimum: 2, maximum: 100 }
  validates :expression, presence: true
  validates :result, presence: true
  validates :category, presence: true, inclusion: { in: %w[custom formula conversion constant] }
  
  scope :by_category, ->(category) { where(category: category) }
  scope :recent, -> { order(created_at: :desc) }
  scope :alphabetical, -> { order(:name) }
  
  CATEGORIES = {
    'custom' => 'Custom Calculation',
    'formula' => 'Mathematical Formula',
    'conversion' => 'Unit Conversion',
    'constant' => 'Mathematical Constant'
  }
  
  def self.get_by_category(category)
    by_category(category)
  end
  
  def self.popular
    joins(:calculation_history)
      .group('favorite_calculations.id')
      .order('COUNT(calculation_histories.id) DESC')
      .limit(10)
  end
  
  def self.search(query)
    where("name ILIKE ? OR expression ILIKE ?", "%#{query}%", "%#{query}%")
  end
  
  def category_name
    CATEGORIES[category]
  end
  
  def to_param
    "#{id}-#{name.parameterize}"
  end
end
50 lines•1.5 KB
ruby
🚀 Support RSK World

Subscribe to our YouTube channel for latest tutorials & updates!



Click subscribe & support our work ❤️

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