RailsMaint is a simple and customizable maintenance mode gem for Rails applications. It allows you to display a sleek maintenance page to your users during maintenance work.
- 🚀 Easy setup and usage
- 🎨 Customizable, modern maintenance page design
- 🌍 Multi-language support (English and Turkish)
- 🔒 IP whitelist support
- 💻 Simple CLI commands
- 🎯 Rails Middleware integration
- Add this line to your application's Gemfile:
gem 'rails_maint'
- Execute:
bundle install
- Add the middleware to your Rails application's
config/application.rb
:
config.middleware.use RailsMaint::Middleware
# For English (default)
rails_maint install
# For Turkish
rails_maint install --locale=tr
This command creates the following files:
config/rails_maint.yml
- Configuration fileconfig/locales/rails_maint.{locale}.yml
- Language file
# To enable maintenance mode
rails_maint enable
# To disable maintenance mode
rails_maint disable
# To remove all files
rails_maint uninstall
You can customize your settings in config/rails_maint.yml
:
# Default language setting
locale: en
# IP addresses allowed to access
white_listed_ips:
- 127.0.0.1
- ::1
# Add your IPs
# - 192.168.1.1
Language files are stored in the config/locales
directory. You can customize existing translations or add new languages:
# config/locales/rails_maint.en.yml
en:
rails_maint:
title: "System Maintenance"
description: "Our system is currently being updated..."
estimated_time: "Estimated time: 1 hour"
# config/locales/rails_maint.tr.yml
tr:
rails_maint:
title: "Sistem Bakımda"
description: "Sistemimiz şu anda güncelleniyor..."
estimated_time: "Tahmini süre: 1 saat"
- When maintenance mode is active, IPs in the whitelist can access the site normally
- All other IPs will see the maintenance page
- If behind a proxy, the gem checks the X-Forwarded-For header
- Each IP should be added to the configuration file
- Clone the repository
- Install dependencies:
bundle install
- Run tests:
bundle exec rspec
The maintenance page template can be customized by creating your own version in public/maintenance.html
. The default template includes:
- Responsive design
- Animated maintenance icon
- Clean and modern layout
- Estimated time display
- Rails 6.0 or higher
- Ruby 2.6 or higher
- Fork it
- Create your feature branch (
git checkout -b feature/amazing_feature
) - Commit your changes (
git commit -m 'Add some amazing feature'
) - Push to the branch (
git push origin feature/amazing_feature
) - Create a Pull Request
- Always test your changes
- Follow the Ruby Style Guide
- Write meaningful commit messages
- Add tests for new features
- Update documentation when needed
Make sure your IP is correctly added to the configuration file and you're not behind an unexpected proxy.
Verify that:
- The locale file exists
- The locale is correctly set in the configuration
- The Rails server was restarted after changes
- The gem uses Rails' built-in security features
- IP validation is performed securely
- No sensitive information is exposed
The gem is available as open source under the terms of the MIT License.
- GitHub Issues: rails_maint/issues
- Email: [email protected]
Developed and maintained by CodesCaptain
See CHANGELOG.md for a list of changes.