This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
1. install rack-cors gem (https://github.com/cyu/rack-cors) | |
gem 'rack-cors', :require => 'rack/cors' | |
2. add to application.rb | |
config.middleware.insert_before "Rack::Lock", "Rack::Cors", :debug => true, :logger => Rails.logger do | |
allow do | |
origins '*' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Tested on: Databables 1.8.2 | |
Datatables comes with controls for filtering and pagination. These can be shown and hidden in a couple of ways (all examples in coffeescript): | |
Way 1 | |
$("#myTable").dataTable | |
"bPaginate": false, #hide pagination control | |
"bFilter": false #hide filter control |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import Ember from 'ember'; | |
export default Ember.Controller.extend({ | |
appName: 'Ember Twiddle' | |
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Tested on: Rails 3.1.x, Heroku Cedar stack | |
1. Generate/develop local Rails app, add mongoid gem, bundle install etc. | |
2. Git the App | |
3. Generate Heroku Cedar App: | |
heroku create --stack cedar | |
4. Rename app | |
heroku rename <newname> | |
5. Install heroku mongoHQ or mongolab: | |
heroku addons:add mongohq:free |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
defmodule PhoenixTimeline.Game do | |
... | |
schema "games" do | |
belongs_to :winner, PhoenixTimeline.Player | |
has_many :players, PhoenixTimeline.Player | |
... | |
end | |
... | |
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
store.getById | |
sync return rec from store if avail or return null | |
e.g. | |
var post = store.getById('post', 1); | |
filter: function(type, query, filter) | |
@param {Class} type | |
@param {Function} filter |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
In general: | |
1. somepropBinding=val => someprop=val | |
2. except for classNameBindings | |
e.g. classNameBindings=":option isSelected:selected" | |
for example: | |
{{#linkTo | |
option.path | |
typeBinding=option.value |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
https://github.com/emberjs/ember.js/pull/3182 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
v: 9.1.4 | |
if have table users: | |
id is_admin | |
-- -------- | |
1 t | |
2 f | |
3 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Tested on: Datatable 1.8.2, Rails 3.1.3 | |
This example uses Coffeescript and Haml (you should too :-) ) | |
The following is an example of Datatables server-side processing of a table | |
which displays a user's song list including the songs' artist names. In | |
Rails, Song and Artist are ActiveRecord models in a one artist-many song relat. | |
1a. the Rails controller code | |
class SongsController < ApplicationController |