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 blogto generate app./script/serverto run the server locally./script/generate controllerto run the blog (router and views)- create index action render "hello world" text
app/views/blog/index.rhtmltemplate - automatically renders with no handler- create posts table with id and title
./script/generate model./script/generate model Postscaffold :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 :postwas 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_tomethods 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 /
- a bunch of generated actions. this is compiling out what
textilemarkup language for text- extract _post.rhtml template to render partials for collections in /
- in the show page, render the partial
./script/generate model CommentPost has_many :comments- in db UI, create
commentstable,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.commentsin theshow.rhtmlpage - create comment form
- comment action in the blog controller, find the one with id (specify in the
form)
- flash "notice" at the top of the screen is funky
- loop over the
rake statsto 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