Skip to content

Instantly share code, notes, and snippets.

View hadrienblanc's full-sized avatar

Hadrien Blanc hadrienblanc

  • Paris, France
View GitHub Profile
@hadrienblanc
hadrienblanc / Readme.md
Created April 1, 2019 13:55
link_to_document.md

Ancestry and Active record serializer

To have every child node included and serialized :

@business_stuff = BusinessStuff.commercial_subtree.arrange_serializable do |parent, children|
  BusinessStuffSerializer.new(parent, children: children)
end

render json: @business_stuff, include: '**'
@hadrienblanc
hadrienblanc / how-to.md
Created April 12, 2019 12:35
devise_token_auth getting-started

Devise

Gemfile

gem 'devise'
gem 'devise_token_auth'

(bundle install)

Terminal :

#
# Tu joues une partie de cartes et durant la partie, tu peux soit gagner 1 point, soit gagner 2 points par manche.
# Le but étant d’arriver à 26 points.
# Quelles sont les différentes combinaisons de points possibles durant le jeu afin d’arriver à 26 points ?
# Exemple pour un total de 3 points, il y a 3 combinaisons : 1/1/1 – 2/1 – 1/2
#
possible_combinations = []
possible_play = [1, 2]
range_of_games_played = 13..26

Are you doing a array of hashes ? They merge. :/

Unless you as: :json on the test post

    post api_v1_stuff, params: params, as: :json
@hadrienblanc
hadrienblanc / config.yml
Created April 29, 2019 09:20
classique circle_ci rails test config file
# classique circle_ci rails test config file
version: 2
jobs:
build:
environment:
working_directory: ~/circleci-myapp
docker:
- image: circleci/ruby:2.5.5-node-browsers
steps:
- checkout

🇺🇸

:en:

class User < ActiveRecord::Base
 def do_something!
   self.my_attr = 123
 end

 def do_another_thing!
   my_attr = 456
end
docker stop $(docker ps -a -q) #stop all docker container