Here are some things that you do in rails and how to do them in joy:
# routes.rb
get '/' => 'home#index'
# app/controllers/home.rb
class HomeController < ApplicationController
def index; end
end
# app/views/home/index.html.erb
<h1>Home</h1>
Just want to point out, that’s three different files for one route
; # routes/pages.janet
(route :get "/" :home)
(defn home [request]
[:h1 "Home"])
class CreatePostsTable < ActiveRecord::Migration[5.1]
def change
create_table :posts do |t|
t.string :title
t.string :body
t.timestamps
end
end
end
-- up
create table posts (
id integer primary key,
title text,
body text,
created_at integer not null default(strftime('%s', 'now')),
updated_at integer
)
-- down
drop table posts
I’ll give it to rails that although it hides a few things, it definitely makes table definitions readable vs plain sql. And it can also do plain sql migrations as well.
rails g scaffold posts title:string body:string
This generates eight files:
routes.rb
fileJoy doesn’t have an equivalent scaffold
generator yet, so you need to run two commands
joy create table posts 'title text' 'body text'
joy create controller posts
This generates two files:
It’s still rails with all of the files and folders to boot.
Rails does a lot of things joy does not:
All of these with the exception of websockets can be done:
As for websockets, it’s coming