ryanwold.net

A civic-minded citizen seeking the singularity

An entry

Walking through the Ember ToDo App

Date: 2015-12-17
Status: release
Tags: ember

Yesterday, I decided to walk-through the https://guides.emberjs.com/v1.10.0/getting-started/, but with the latest ember-cli-rails in Rails 4.2.5.

Here are the results:

Setups

  • javascript stuff - npm, ember-cli
  • ruby stuff - rails, ember-cli-rails

Concepts

  • router -> controller -> component -> view -> template.hbs
    • In Ember, when a URL changes, a route event is dispatched. The behavior of dispatched events are handled by router.js.
  • Ember data is largish on its own. Check it out.

  • Router accepts URL patterns. For example, define what responds to /todos, or /images/37. Routers are opinionated, so a request to /todos will expect a Controller called TodosController. And since Ember now uses modules, it relies on file naming (and pathing) conventions. So, TodosController can live at /app/controllers/todos.js, or /app/pods/todos/controller.js. TodoController will require the same, and handle 1 Todo, rather than all Todos, like TodoController.

  • Controller does stuff

  • Model serializes and manages data

  • Views - logic

  • Templates - view logic and ultimately, HTML

Gotchas

  • beware of file-naming. So, be aware of Ember's file-naming conventions, and stick to them.
  • use active-model-adapter plugin for Ember to help with isCompleted -> is_completed naming convention conversions
  • be sure to run rails g ember:heroku from your Rails app - more details here - to generate /bin/heroku_install

More notes to come...