Skip to content

Instantly share code, notes, and snippets.

@PhilippePerret
PhilippePerret / temps_helper.rb
Created January 5, 2012 17:25
Helper de temps/date
# Helper de temps
#
module TempsHelper
# Note :
# Les fichiers locales (`config/locales/...`) doivent définir des données
# pour pouvoir utiliser les formats :
# :humain # => 05 janvier 2012
# :humain_court # => 05 jan 2012
# :court_avec_heure # => 05 02 2012 - 18:24
@PhilippePerret
PhilippePerret / date_fr.yml
Created January 5, 2012 17:23
locales/generales/fr.yml
fr:
# Pour utiliser la méthode 'formate_date' de l'helper Temps du fichier :
# https://gist.github.com/1566244
date:
abbr_day_names: ["dim", "lun", "mar", "mer", "jeu", "ven", "sam"]
abbr_month_names: ["~", "jan", "fév", "mar", "avr", "mai", "jui", "juil", "août", "sept", "oct", "nov", "déc"]
day_names: ["dimanche", "lundi", "mardi", "mercredi", "jeudi", "vendredi", "samedi"]
month_names: ["~", "janvier", "février", "mars", "avril", "mai", "juin", "juillet", "août", "septembre", "octobre", "novembre", "décembre"]
time:
@PhilippePerret
PhilippePerret / spec_helper.rb_in_spec
Created January 5, 2012 09:30
Spec helper (Rails 3.1)
# Inclure ce fichier dans tous les tests avec :
# require 'spec_helper'
ENV["RAILS_ENV"] ||= 'test'
require File.expand_path("../../config/environment", __FILE__)
require 'rspec/rails'
require 'rspec/autorun'
require 'capybara/rspec'
# Requires supporting ruby files with custom matchers and macros, etc,
@PhilippePerret
PhilippePerret / deploiement_avec_capitrano
Created December 26, 2011 10:15
Déploiement avec Capistrano
# Si on utilise whenever pour des cron jobs
# Pour actualiser le crontab à chaque déploiemnet
after "deploy:symlink", "deploy:update_crontab"
namespace :deploy do
desc "Update the crontab file"
task :update_crontab, :roles => :db do
run "cd #{release_path} && whenever --update-crontab #{application}"
end
@PhilippePerret
PhilippePerret / new.html.haml
Created November 10, 2011 09:48
Application Rails 3.1 avec Devise — Création de l'utilisateur
> in app/views/devise/registrations/new.html.haml
= form_for(resource, :as => resource_name, :url => registration_path(resource_name)) do |f|
= devise_error_messages!
%table
%tr
%td
= f.label :name, "Nom"
%td
= f.text_field :name
@PhilippePerret
PhilippePerret / edit.html.haml
Created November 10, 2011 09:46
Application Rails 3.1 avec Devise — Edition de l'utilisateur
> in app/views/devise/registrations/edit.html.haml
= form_for(resource, :as => resource_name, :url => registration_path(resource_name)) do |f|
= devise_error_messages!
%table
%tr
%td
= f.label :name, "Nom"
%td
= f.text_field :name
@PhilippePerret
PhilippePerret / creation_app_rails_31
Created November 7, 2011 07:54
Étapes de création d'une application Rails 3.1
# Rails 3.1 doit être installé sur la machine
#--------------------------------------------------------------------------
# OUTILS UTILISÉS
#
#
# Outils utilisés :
# - TextMate comme éditeur de texte
# - Terminal comme console (mais TextMate peut être utilisé aussi)
# - Firefox comme navigateur de développement
@PhilippePerret
PhilippePerret / gemfile_31
Created November 7, 2011 06:47
Gemfile pour application Rails 3.1
source 'http://rubygems.org'
gem 'rails', '3.1.0'
gem 'sqlite3'
gem 'sqlite3-ruby', '1.3.2', :require => 'sqlite3'
gem "rubyzip", '0.9.4'
gem 'json'