A framework for JS MVC apps
(Let's not get in a debate as to whether it's really MVC when we say JS MVC, ok?)
Typically loaded and saved to a server, but doesn't have to be
Most importantly, handles URLs and sends messages the correct Controller for what is being requested
Like Rails!
This is the volatile ember-data
project; now a part of Ember.js itself
Other frameworks leave calling render
up to you
Other frameworks let you turn this on
Other frameworks (like Backbone) are more like LEGO blocks
You can combine those frameworks in many ways
Ember is a set of reasonable defaults
Because Discourse is a forum system on Rails and Ember, and we want to party like it's 1999!
Routes:
app/models/entry.rb
app/controllers/entries_controller.rb
(no views!)
active_model_serializers
rails generate resource entry
as before gives us:app/serializers/entry_serializer.rb
:
ember-rails
Works with the same rails generate resource entry
command we used earlier.
active_model_serializers
gives us the API expected by ember-data
From rails generate resource entry
with ember-rails
, we get:
application.js
Requires all our code and instantiates the Ember app.
guest_book_app.js
Our application code, in turn, requires all of the Ember application classes:
store.js
:
Keeps track of the ember-data
API version we're on
router.js
:
(by default)
router.js
with changes:
Create and view guest book entries in addition to an index
/routes/entries_routes.js
:
/controllers/entries_controller.js
:
/models/entry.js
:
ember-data
being a different project.
```
/views/entries_view.js
:
Our template for the application:
/templates/application.handlebars
:
/templates/entries.handlebars
:
This presentation lives at:
blog.mattgauger.com/madrailers-ember-rails/
My example raffle app lives at:
/