top | item 40791011

(no title)

cassiogo | 1 year ago

Not that I think this is pratical or even looks good, but its also doable with rails

  require 'bundler/inline'

  gemfile(true) do
    source 'https://rubygems.org'

    gem 'rails', '~> 7.1'
    gem "sqlite3", "~> 1.4"
  end

  require 'rails'
  require 'active_record/railtie'
  database = 'app_development.sqlite3'

  ENV['DATABASE_URL'] = "sqlite3:#{database}"
  ActiveRecord::Base.establish_connection(adapter: 'sqlite3', database: database)
  ActiveRecord::Schema.define do
    create_table :my_table, force: true do |t|
      t.integer :my_table_id
    end
  end

  class App < Rails::Application
    routes.append do
      root to: 'home#index'
    end
  end

  class HomeController < ActionController::Base
    def index
      render inline: 'HOME'
    end
  end

  App.initialize!

  run App
For very small apps on ruby land sinatra and roda are the right choices. On python the choice would be flask instead of the single file django.

discuss

order

mg|1 year ago

Is the db mandatory in Rails or could the db specific lines be removed from the code if no db is needed?

cassiogo|1 year ago

Not mandatory, you could remove that