Skip to content

Instantly share code, notes, and snippets.

@Myuzu
Last active December 17, 2024 15:01
Show Gist options
  • Save Myuzu/883f556fb22ff5dcbf682747b7940581 to your computer and use it in GitHub Desktop.
Save Myuzu/883f556fb22ff5dcbf682747b7940581 to your computer and use it in GitHub Desktop.
Single file working Rails 8 app, with dependancies spec inside
require 'bundler/inline'
gemfile do
source 'https://rubygems.org'
ruby '3.3.0'
gem 'rails', '~> 8.0.0'
gem 'puma'
gem 'rackup'
end
require 'action_controller/railtie'
module Controllers
class HomeController < ActionController::Metal
def index
self.response_body = '<h1>Hello from Rails 8!</h1>'
end
end
end
class MinimalApp < Rails::Application
# Set Rails configuration
config.root = __dir__
config.secret_key_base = 'random_secret_key_base'
# Initialize configuration defaults for Rails 8.0
config.load_defaults 8.0
# Disable unnecessary Rails features
config.eager_load = false
config.logger = Logger.new($stdout)
config.log_level = :debug
# Initialize and run the application
initialize!
# Register our controller
ActiveSupport.on_load(:action_controller) do
include Controllers
end
end
# Routes configuration
MinimalApp.routes.draw do
root to: Controllers::HomeController.action(:index)
end
# Rackup configuration
if __FILE__ == $0
require 'rackup'
Rackup::Server.start(
app: MinimalApp,
Port: 3000,
Host: '0.0.0.0'
)
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment