Now we’re actually going to code.
We are going to build a CRM. This is a good project for Ember because we’ll be searching, listing, showing, creating, and editing records. If you can build this app and understand how it works then you will be well on your way to developing your own complex front-end apps.
The main object in this system is the lead. If you don’t know the term, a lead is the same thing as a potential customer.
You can use the Hello World app we built earlier as the base for this app. I’m going to provide you with styles so that you can just focus on the Ember stuff:
Download this stylesheet and save it to
app/assets/stylesheets/application.css, replacing your existing
If you use Vim, there’s a very useful plugin called vim-projectionist that provides some help in navigating files. Vim projections are great for quickly opening and creating Ember files.
config/projections.json and restart Vim.
These projections use
Ej as a prefix for all things Ember, so you have
Ejini will open your Ember router, which is consistent with
Eini opening your Rails router.
If you don’t use Vim, consider learning it. It will probably improve your programming experience. You can open a terminal and type
vimtutor to get an instant tutorial. You might also check out VimGenius, a little app I built to help you remember commands. Lastly, I wrote a Vim Tutorial that will help you get to an intermediate level.
Let’s use the AutoLocation API to get rid of hashes in our urls. We also need to set the rootURL to
'/' so Ember knows where to start parsing the url from.
Open your router and add the following to the top:
We also need to create a catch-all Rails route to handle whatever arbitrary routes we create in Ember, otherwise we’ll get a 404 when we try to reload the page on an Ember subroute:
# config/routes.rb # add this to the bottom of your Rails routes get '*path', to: 'home#index'