Skip to content

Instantly share code, notes, and snippets.

App.IndexRoute = Ember.Route.extend({
renderTemplate: function() {
this.render();
}
});
App.FooController = Ember.Controller.extend({
say: function(msg) {
console.log("Hello " + msg);
}
});
App.IndexRoute = Ember.Route.extend({
controllerName: 'foo',
setupController: function(controller) {
controller.say("world");
App.IndexController = Ember.Controller.extend({
say: function(msg) {
console.log("Hello " + msg);
}
});
App.IndexRoute = Ember.Route.extend({
setupController: function(controller) {
controller.say("world");
}
App.IndexRoute = Ember.Route.extend({
beforeModel: function() {
console.log("beforeModel");
},
model: function() {
console.log("model")
},
afterModel: function() {
console.log("afterModel");
},
@marcioj
marcioj / app.js
Last active August 29, 2015 14:15
App = Ember.Application.create();
App.Router.map(function() {
// put your routes here
});
App.IndexRoute = Ember.Route.extend({
model: function() {
return "Hello world";
}
@marcioj
marcioj / main.rb
Created January 18, 2015 01:26
Recursive hash creation in ruby
h = Hash.new {|h,k| h[k] = Hash.new(&h.default_proc) } # => {}
h[:a] = 1 # => 1
h[:b][:c] = 2 # => 2
h[:c][:d] = 3 # => 3
h # => {:a=>1, :b=>{:c=>2}, :c=>{:d=>3}}
@marcioj
marcioj / _form.html.slim
Last active August 29, 2015 14:13
Rerenders the result of an ajax request into the fancybox modal. Good for form redisplays
= simple_form_for([@topic], remote: true, data: { "rerender-inside-modal" => true }) do |f|
= f.input :name
= f.input :content
= f.submit
@marcioj
marcioj / app.pt-BR.yml
Last active August 29, 2015 14:13
Enum with brazilian states using enumerize gem
pt-BR:
enumerize:
defaults:
state:
ac: Acre
al: Alagoas
ap: Amapá
am: Amazonas
ba: Bahia
ce: Ceará
@marcioj
marcioj / controller_macro.rb
Created January 13, 2015 20:44
Devise rspec controller macro
# Taken from https://github.com/plataformatec/devise/wiki/How-To:-Test-controllers-with-Rails-3-and-4-(and-RSpec),
# with some minor changes
module ControllerMacros
def login_admin(&proc)
before(:each) do
@request.env["devise.mapping"] = Devise.mappings[:admin]
admin_user = proc ? instance_eval(&proc): FactoryGirl.create(:admin_user)
sign_in admin_user
end
@marcioj
marcioj / index.js
Created December 2, 2014 04:09
Regenerator
// app/routes/users/index.js
import Ember from 'ember';
export default Ember.Route.extend({
actions: {
remove: function(model) {
if(confirm('Are you sure?')) {
model.destroyRecord();
}