Skip to content

Instantly share code, notes, and snippets.

View shwoodard's full-sized avatar

Sam Woodard shwoodard

View GitHub Profile
<form>
<label for="story_title">Add story</label>
{{view Ember.TextField valueBinding="view.storyTitle" id="story_title"}}
<button class="btn btn-primary" {{action createStory target="view"}}>Create</button>
</form>
App.NewStoryView = Ember.View.extend
storyTitle: null
templateName: 'stories/new'
classNameBindings: ['hide']
hide: false
storyTitleDidChange: (->
console.log @toString()
console.log @get('storyTitle')
).observes('storyTitle')
class ProjectSerializer < ActiveModel::Serializer
embed :ids, :include => true
attributes :id, :name
has_many :solutions
def as_json(options = {})
hash = super(options)
hash[:solutions].each{|solution| solution.delete(:stories) }
hash.delete(:stories)
hash
@shwoodard
shwoodard / gist:3382934
Created August 17, 2012 21:34
intern symbol
class Symbol
def intern
self
end
end
@shwoodard
shwoodard / ckeditor.rb
Created August 9, 2012 21:13
RSpec + Capybara support file to work with ckeditor instances
module Ckeditor
class Instance
attr_reader :capybara
private :capybara
def initialize(instance_id, capybara)
@instance_id, @capybara = instance_id, capybara
end
def val(value)
...
# Gems used only for assets and not required
# in production environments by default.
group :assets do
gem 'sass-rails'
gem 'coffee-rails'
gem 'libv8', '~> 3.11.8'
# See https://github.com/sstephenson/execjs#readme for more supported runtimes
@shwoodard
shwoodard / lib.coffee
Created July 6, 2012 15:11
Some useful functions when developing ember apps
window.delay = (duration, toRun) ->
Ember.run.later(toRun, duration)
window.waitUntil = (context, interval, toRun, condition) ->
if condition.call(context)
return toRun.call(context)
delay interval, ->
waitUntil(context, interval, toRun, condition)
Umbrella.ShowProjectView = Ember.ContainerView.extend
classNames: ['projects_show', 'row']
contentBinding: 'controller'
childViews: ['projectImagesIndexView']
projectImagesIndexView: Ember.ContainerView.create
contentBinding: 'controller.projectImages'
childViews:[Umbrella.ProjectSlideshowView.create()]
Umbrella.Router = Ember.Router.extend
enableLogging: true
root: Ember.Route.extend
index: Ember.Route.extend
route: '/'
redirectsTo: 'projects'
projects: Ember.Route.extend
Umbrella.NewProjectDiscussionView = Ember.View.extend
contentBinding: 'controller'
tagName: 'form'
templateName: 'project_discussions/new'
submit: ->
Umbrella.store.createRecord Umbrella.ProjectDiscussion,
body: this.get('body')
project: this.get('content').objectAt('0').get('project')
Umbrella.store.commit()