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
.
- In Ember, when a URL changes, a route event is dispatched. The behavior of dispatched events are handled by
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 calledTodosController
. 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, likeTodoController
.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...