Val Town is a collaborative website to build and scale JavaScript apps.
Deploy APIs, crons, & store data – all from the browser, and deployed in milliseconds.
  • rails blog to generate app
  • ./script/server to run the server locally
  • ./script/generate controller to run the blog (router and views)
  • create index action render "hello world" text
  • app/views/blog/index.rhtml template - automatically renders with no handler
  • create posts table with id and title
  • ./script/generate model
  • ./script/generate model Post
  • scaffold :post - putting model object online to edit -> CRUD views
  • add body text field -> added to all views automatically without restarting or compiling, all happens at runtime!
  • validation, ie "non null" in model and shown in the ui
  • ./script/generate scaffold Post Blog
    • a bunch of generated actions. this is compiling out what scaffold :post was doing at runtime to static code
    • Edits the template to look how we want
    • "People learn by changing a little thing. Reloading and seeing the change"
    • link_to methods we can call in the view
    • changed the index view to be pretty, the other create and view and edit routes look the same for now
    • reverse the list in /
  • textile markup language for text
  • extract _post.rhtml template to render partials for collections in /
  • in the show page, render the partial
  • ./script/generate model Comment
    • Post has_many :comments
    • in db UI, create comments table, post_id - rails figures out that's the foreign key
    • manually creates a new commend in the db ui
  • in the show page
    • loop over the @post.comments in the show.rhtml page
    • create comment form
    • comment action in the blog controller, find the one with id (specify in the form) Screenshot 2026-05-26 at 13.33.10@2x.png
    • flash "notice" at the top of the screen is funky
  • rake stats to see how much code we create - "58 lines of code"
  • look at the logs to see the sql being generated ("because we didn't write any sql")
  • run the tests, two tests passing for the 2 model objects - adds a comment and then checks if the post has a comment (after "reloading the object")
  • ./script/console Screenshot 2026-05-26 at 13.38.27@2x.png