Skip to content

Instantly share code, notes, and snippets.

View zedtux's full-sized avatar

Guillaume Hain zedtux

View GitHub Profile
@zedtux
zedtux / show_right.rb
Created October 8, 2016 11:45
Using Right and RightLevel with the renamed has_many association
right = Right.find(1)
level = right.levels.first
puts level.level
@zedtux
zedtux / right.rb
Created October 8, 2016 11:44
Right model with a renamed has_many association
class Right
has_many :levels, :class_name => ‘RightLevel’, :foreign_key => ‘right_id’
end
@zedtux
zedtux / right_module.rb
Created October 8, 2016 11:41
RightModule with renamed associations
class RightModule
belongs_to :package, :class_name => ‘RightPacakge’
had_many :function_groups, :class_name => ‘RightFunctionGroup’, :foreign_key => ‘right_module_id’
end
@zedtux
zedtux / rails.rake
Created October 15, 2015 13:40
Capistrano 3 recipe which allow opening a Rails console
namespace :rails do
desc 'Remote console'
task :console do
on roles(:app) do |h|
command = 'rails console'
run_interactively "RAILS_ENV=#{fetch(:rails_env)} bundle exec #{command}",
h.user
end
end
@zedtux
zedtux / keybase.md
Created May 5, 2015 16:52
keybase.md

Keybase proof

I hereby claim:

  • I am zedtux on github.
  • I am zedtux (https://keybase.io/zedtux) on keybase.
  • I have a public key whose fingerprint is BC63 F4AE B4B5 092E 3104 C289 D2B2 A8B9 9474 CF36

To claim this, I am signing this object:

@zedtux
zedtux / Dockerfile
Last active August 29, 2015 14:20
Switchery-rails Dockerfile
# Switchery-rails gem Dockerfile
# ~~~~ Image base ~~~~
# Base image with the latest Ruby only
FROM litaio/ruby:2.2.2
MAINTAINER Guillaume Hain [email protected]
# ~~~~ Set up the environment ~~~~
ENV DEBIAN_FRONTEND noninteractive
@zedtux
zedtux / test.rb
Created February 1, 2015 11:20
A test.rb that you don't care at all :)
Rails.application.configure do
# Settings specified here will take precedence over those in
# config/application.rb.
# The test environment is used exclusively to run your application's
# test suite. You never need to work with it otherwise. Remember that
# your test database is "scratch space" for the test suite and is wiped
# and recreated between test runs. Don't rely on the data there!
config.cache_classes = true
@zedtux
zedtux / env.rb
Created February 1, 2015 11:16
A cucumber env.rb that you don't care at all :)
# IMPORTANT: This file is generated by cucumber-rails - edit at your own peril.
# It is recommended to regenerate this file in the future when you upgrade to a
# newer version of cucumber-rails. Consider adding your own code to a new file
# instead of editing this one. Cucumber will automatically load all
# features/**/*.rb files.
$stdout.sync = true if ENV['RUN_IN_DOCKER'] == 'true'
ENV['RAILS_ENV'] ||= 'test'
ENV['RAILS_ENV'] = 'test' if ENV['RAILS_ENV'] == 'development'
@zedtux
zedtux / fig.yml
Created January 13, 2015 17:15
Brewformluas.org fig.yml file
postgresql:
image: postgres:9
redis:
image: redis:2.8
web:
build: .
command: bin/rails server -e production
links:
- postgresql
- redis
@zedtux
zedtux / bundle.env
Created January 10, 2015 11:22
bundle env
Bundler 1.7.11
Ruby 2.2.0 (2014-12-25 patchlevel 0) [x86_64-linux]
Rubygems 2.4.5
GEM_HOME /usr/local/lib/ruby/gems/2.2.0
GEM_PATH
Bundler settings
cache_all
Set for your local app (/cursus-scholar/application/.bundle/config): "true"