Skip to content

Instantly share code, notes, and snippets.

Routing in Ember

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 "/",
# Monkey Patch ruby because of a bug introduced in ruby versions greater than 1.9.2
# For some reason the exit code is all wrong in later version of ruby and even though
# the issue was closed as sorted it's still broken in ruby version 1.9.3-p194.
# (see http://redmine.ruby-lang.org/issues/5218 for more information)
# Put this in spec_helper.rb or test_helper.rb so that it only affects specs and the CI server.
if defined?(RUBY_ENGINE) && RUBY_ENGINE == "ruby" && RUBY_VERSION >= "1.9"
module Kernel
alias :__at_exit :at_exit
def at_exit(&block)
__at_exit do
<?xml version="1.0" encoding="UTF-8"?>
<CORSConfiguration xmlns="http://s3.amazonaws.com/doc/2006-03-01/">
<CORSRule>
<AllowedOrigin>*</AllowedOrigin>
<AllowedMethod>GET</AllowedMethod>
<MaxAgeSeconds>3000</MaxAgeSeconds>
<AllowedHeader>*</AllowedHeader>
</CORSRule>
</CORSConfiguration>
@adamthedeveloper
adamthedeveloper / binary_tree_insert.rb
Last active December 20, 2015 02:49
Rebuild a binary tree from an array.
class Node
attr_accessor :data, :left, :right
def initialize(*args)
@data,@left,@right = args
end
end
class Tree
attr_accessor :root
@adamthedeveloper
adamthedeveloper / gist:7538338
Created November 19, 2013 00:59
Increment / Decrement coffeescript
window.ChangeQuantity ||= {}
ChangeQuantity.load = ()->
$("input.change-quantity").click((evnt)->
evnt.preventDefault()
quantityField = $(this).parent().find('input.quantity')
currVal = parseInt(quantityField.val())
@adamthedeveloper
adamthedeveloper / TerminalGitBranchPrompt
Created November 20, 2013 23:59
Show your current branch in your terminal. Add this to the bottom of you .bash_profile
# Git branch in prompt.
parse_git_branch() {
git branch 2> /dev/null | sed -e '/^[^*]/d' -e 's/* \(.*\)/ (\1)/'
}
export PS1="\u@\h \W\[\033[32m\]\$(parse_git_branch)\[\033[00m\] $ "
source ~/.profile
@adamthedeveloper
adamthedeveloper / SalesReceiptAdd.xml
Created June 5, 2014 23:38
QB SalesReceiptAdd XML
<?xml version="1.0" encoding="utf-8"?>
<?qbxml version="13.0"?>
<QBXML>
<QBXMLMsgsRq onError="stopOnError">
<SalesReceiptAddRq>
<SalesReceiptAdd defMacro="MACROTYPE"> <!-- required -->
<CustomerRef> <!-- optional -->
<ListID >IDTYPE</ListID> <!-- optional -->
<FullName >STRTYPE</FullName> <!-- optional -->
</CustomerRef>
@adamthedeveloper
adamthedeveloper / asi_search_for_pens
Created March 30, 2017 18:01
These are the results returned when I searched for "pens"
{
"Results": [
{
"Id": 550518851,
"Name": "Tri-Band Ballpoint Pen",
"Description": "Tri-band ballpoint pen with silver trim and black rubber grip for writing comfort and control. These tri-band ballpoint pens include plunger action. These tri-band ballpoint pens are also available in a variety of new colors! Tri-band ballpoint pens are a great giveaway for any event or trade show. Ensure your clients remember you and write away the competition with these great ballpoint pens!",
"Number": "AZ898",
"ImageUrl": "media/22117985",
"VirtualSampleImages": [
{
{
"Id": 550518851,
"Name": "Tri-Band Ballpoint Pen",
"Description": "Tri-band ballpoint pen with silver trim and black rubber grip for writing comfort and control. These tri-band ballpoint pens include plunger action. These tri-band ballpoint pens are also available in a variety of new colors! Tri-band ballpoint pens are a great giveaway for any event or trade show. Ensure your clients remember you and write away the competition with these great ballpoint pens!",
"ShortDescription": "Tri-band ballpoint pen with silver trim and black rubber grip. Rubber grip and silver trim on tri-band ballpoint pens.",
"Number": "AZ898",
"Numbers": [
"AZ898"
],
"ImageUrl": "media/22117985",
@adamthedeveloper
adamthedeveloper / json
Created April 7, 2017 19:10
asi_result_for_bel_promo_trophy.json
{"Id"=>550201890,
"Name"=>"Spear Glass Trophies",
"Description"=>
"Cut right to the heart of the matter when you acknowledge the accomplishments of your employees with these Spear Glass Trophies. These exquisite blue and clear awards have a 2.25\" x 3\" imprint area that you can customize using laser engraving or you can order them blank. The glass trophies measure 9\" H x 5.75\" W x 0.4\" thick and will be the envy of the office. They are perfect for your top sales people, employee of the month and any other special achievements in the company. Show your employees that you value everything they bring to the business!",
"ShortDescription"=>"Spear Glass Trophies",
"Number"=>"ADMAW16",
"Numbers"=>["ADMAW16"],
"ImageUrl"=>"media/20816194",
"VirtualSampleImages"=>
[{"Id"=>20816194,