How To: CRUD with Validation in Ember.js Using ember-easyForm, ember-validations, and Boostrap

One of the basic building blocks of any web application is CRUD, or Create, Read, Update and Delete. It allows users and administrators to manage the data in the application. Full-stack server-side MVC frameworks like Django or Ruby on Rails provide code generators that give you all the code needed for a basic CRUD interface. But what if you were using Ember.js to build your application? Ember.js does not provide any code generators, and there is no established idiom or best practices for CRUD in Ember.js. In this series I will show how to build a basic CRUD interface in Ember.js, complete with user input validation.

In this example, we will build a CRUD interface for products in an online book store.

The tools that we will use are:

  • Ember.js, our framework
  • Ember Data, the official model library for Ember.js
  • ember-easyForm, a set of helpers to easily build forms in Ember.js
  • ember-validations, a declarative system for defining data validations in Ember.js
  • Bootstrap, a CSS framework to make our application look pretty
  • QUnit, to test our application

Step 1. Set Up

Before we get started, we need to set up Ember.js and our dependencies. We do that by creating index.html and inserting <link> and <script> tags to pull in the dependencies:

<!DOCTYPE html>
<html lang="en">
    <meta charset="utf-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1">
    <title>Ember.js CRUD Example</title>

    <!-- Bootstrap -->
    <link rel="stylesheet" href="">
    <!-- QUnit -->
    <link rel="stylesheet" href="">

    <!-- HTML5 Shim and Respond.js IE8 support of HTML5 elements and media queries -->
    <!-- WARNING: Respond.js doesn't work if you view the page via file:// -->
    <!--[if lt IE 9]>
      <script src=""></script>
      <script src=""></script>
    <div id="qunit"></div>
    <div id="qunit-fixture"></div>
    <div id="qunit-tests"></div>

    <script type="text/x-handlebars">
      <div id="application" class="container-fluid">
        <div class="row">
          <div id="left-nav" class="col-md-3" style="background-color: #eeeeee">
            <ul class="nav nav-pills nav-stacked sidebar">
              {{#link-to "index" tagName="li"}}{{#link-to "index"}}Dashboard{{/link-to}}{{/link-to}}
          <div id="main" class="col-md-9">

    <script type="text/x-handlebars" data-template-name="index">
      <div class="jumbotron">
        <p>This app demonstrates CRUD with validation in Ember.js</p>

    <!-- jQuery -->
    <script src=""></script>
    <!-- Handlebars -->
    <script src=""></script>
    <!-- Ember.js -->
    <script src=""></script>
    <script src=""></script>
    <!-- ember-easyForm -->
    <script src=""></script>
    <!-- ember-validations -->
    <script src=""></script>
    <!-- Bootstrap -->
    <script src=""></script>
    <!-- QUnit -->
    <script src=""></script>

    <!-- JavaScript files for our application and tests -->
    <script src="app.js"></script>
    <script src="tests.js"></script>

Let us also create app.js:

window.App = Ember.Application.create();

App.ApplicationAdapter = DS.FixtureAdapter.extend({
  namespace: 'ember-crud'

And tests.js:

App.rootElement = '#qunit-tests';

module('Integration: Index', {
  setup: function() {

test('app test', function() {

  visit('/').then(function() {
    equal(find('h1').text(), 'Welcome!');

Now if you load index.html in your browser, you should see the welcome message. Ensure that the tests have passed.

You can get the code for this step by running:

git clone
git checkout step-1

5 thoughts on “How To: CRUD with Validation in Ember.js Using ember-easyForm, ember-validations, and Boostrap

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s