Skip to content

Instantly share code, notes, and snippets.

import Ember from 'ember';
export default Ember.Component.extend({
});
import Ember from 'ember';
export default Ember.Route.extend({
model() {
return this.get('store').createRecord('licence');
},
actions: {
saveLicence(newLicence) {
newLicence.save().then(() => this.transitionTo('licences'));
},
@bsylvain
bsylvain / integration.hbs
Last active April 19, 2018 13:02
Button triggering an API call than can fail or succeed
{{the-button isFailure=isFailure isSuccess=isSuccess onCLick=somethingToDo buttonLabel='Do Something'}}
@bsylvain
bsylvain / _factory.rb
Last active April 10, 2018 09:34
factory bot error
FactoryBot.define do
factory :ownership do
transient do
transient_debug_test_name nil
end
user
association :good,factory: :good_produit
pricing
association :period ,datepublication: evaluator.transient_debug_test_name
shop Shop.all.first
@bsylvain
bsylvain / test.rb
Created July 19, 2017 14:05
working test but probably not optimal
start_count = contrat.contrat_lines.count
ServicesContrat::AddToContrat.new(contrat).add(produit.id,produit.pricings.first.id)
assert (contrat.contrat_lines.count) == start_count+1
@bsylvain
bsylvain / ruby_tricks.rb
Created July 12, 2017 09:59 — forked from patriques82/Ruby tricks
A list of Ruby tricks from the book "the ruby programming language"
Equality
The equal? method is defined by Object to test whether two values refer to exactly the same
object. For any two distinct objects, this method always returns false:
a = "Ruby" # One reference to one String object
b = c = "Ruby" # Two references to another String object
a.equal?(b) # false: a and b are different objects
b.equal?(c) # true: b and c refer to the same object
By convention, subclasses never override the equal? method. The == operator is the most common
Unifier !
@bsylvain
bsylvain / model.rb
Created October 13, 2016 12:06
can it be reduced to a one liner ?
validate :relation_with_same_tenant
.......
private
def relation_with_same_tenant
if self.shop_id!=ui_listable.shop_id
self.errors.add(:ui_listable,"ERROR MESSAGE")
$('.sortable').nestedSortable({
forcePlaceholderSize: true,
handle: 'div',
helper: 'clone',
items: 'li',
opacity: .6,
placeholder: 'placeholder',
revert: 250,
tabSize: 25,
tolerance: 'pointer',
tenant A
Familly 1(id: 12,parent: nil,order:1)
|
|--Sub-familly order: 1 parent: 12
|--Sub-familly order: 2 parent: 12
Familly 2(id: 57,order:4)
|--Sub-familly order: 1parent: 57
Tenant B