In Ember, the application's state manager handles routing. Let's take a look at a simple example:
App.stateManager = Ember.StateManager.create({
start: Ember.State.extend({
index: Ember.State.extend({
route: "/",| var mongoose = require('mongoose') | |
| , Schema = mongoose.Schema | |
| , db = mongoose.connect('localhost', 'testing_streaming').connection | |
| , Stream = require('stream').Stream | |
| , express = require('express') | |
| /** | |
| * Dummy schema. | |
| */ |
| /* sample aggregate command queries */ | |
| // make sure we're using the right db; this is the same as "use mydb;" in shell | |
| db = db.getSisterDB("aggdb"); | |
| // just passing through fields | |
| var p1 = db.runCommand( | |
| { aggregate : "article", pipeline : [ | |
| { $project : { | |
| tags : 1, | |
| pageViews : 1 |
| require 'formula' | |
| class Vim < Formula | |
| homepage 'http://www.vim.org/' | |
| url 'ftp://ftp.vim.org/pub/vim/unix/vim-7.3.tar.bz2' | |
| head 'https://vim.googlecode.com/hg/' | |
| sha256 '5c5d5d6e07f1bbc49b6fe3906ff8a7e39b049928b68195b38e3e3d347100221d' | |
| version '7.3.294' | |
| def features; %w(tiny small normal big huge) end |
| moduleKeywords = ['included', 'extended', 'prototype'] | |
| class Class | |
| # Rename an instance method | |
| # | |
| # ``` coffeescript | |
| # class User | |
| # @alias "methods", "instance_methods" | |
| # | |
| # ``` |
| # Have you ever had to sleep() in Capybara-WebKit to wait for AJAX and/or CSS animations? | |
| describe 'Modal' do | |
| should 'display login errors' do | |
| visit root_path | |
| click_link 'My HomeMarks' | |
| within '#login_area' do | |
| fill_in 'email', with: 'will@not.work' | |
| fill_in 'password', with: 'test' |
| module Mongoid | |
| module MassAssignmentSecurity | |
| extend ActiveSupport::Concern | |
| included do | |
| attr_accessible nil | |
| end | |
| end | |
| module Document |
| # Generate TAGS files with bundler projects. Bundle must be updated, and tags binary | |
| # must be exuberant ctags. | |
| namespace :tags do | |
| namespace :generate do | |
| desc <<-EOT | |
| Generate a new emacs TAGS file for the current project. | |
| Requires exuberant ctags and bundler. | |
| EOT | |
| task :emacs do |
Recently, we've been working on extracting Ember conventions from applications we're working on into the framework. Our goal is to make it clearer how the parts of an Ember application work together, and how to organize and bootstrap your objects.
Routing is an important part of web applications. It allows your users to share the URL they see in their browser, and have the same things appear when their friends click on the link.
The Ember.js ecosystem has several great solutions for routing. But, since it is such an important part of most web applications, we've decided to build it right into the framework.
If you have already modeled your application state using Ember.StateManager, there are a few changes you'll need to make to enable routing. Once you've made those changes, you'll notice the browser's address bar spring to life as you start using your app—just by moving between states, Ember.js will update the URL automatically.
| App = Ember.Application.create({}); | |
| App.loginController = Ember.Object.create({ | |
| // do login stuff | |
| }); | |
| App.LoginFormView = Ember.View.extend({ | |
| login: null, | |
| password: null, |