Skip to content

Instantly share code, notes, and snippets.

con.with_connection do | connection |
connection = connection.raw_connection
query_result = connection.exec_params(
"DELETE FROM feed_relation_links
WHERE group_id = $1 AND element_type = $2 AND element_id = $3",
[ _id, _element_type, _element_id]
)
end
class RepositoryUser
def new_user( _user_attrs )
User.new( _user_attrs )
end
def find_by( _attr, _value )
return User.where( [ "? = ?", _attr, _value ] ).first()
end
@Grandvizir
Grandvizir / gist:3f5f11a74cf0498b2ae6
Created January 20, 2015 13:07
Rails initializers
# test/controllers/users_controller_test.rb
class UsersControllerTest < ActionController::TestCase
setup do
@user_admin = User.find_by_email('[email protected]') #=> Not Find..
@user = User.new(email: '[email protected]', name: 'Jean', token: 'plop', public_key: 'plip')
# test helper method
login_as(@user_admin)
end
end
class Project < ActiveRecord::Base
track_who_does_it
belongs_to :organization
has_many :teams, :dependent => :destroy
has_many :trackers, :dependent => :destroy
has_many :layouts, :dependent => :destroy
accepts_nested_attributes_for :trackers, :reject_if => lambda { |a| a[:name].blank? }, :allow_destroy => true
{
"jobs": [
{
"provider": {
"id": "603200674294177794",
"provider": "twitter",
"uploaded_at": "2015-05-26 14:07:02"
},
"author": {
"id": "3031159317",
module Administration
class Administration::BaseController < ApplicationController
layout 'administration'
private
def current_session_process_id(_city_id, _process_id = nil )
session["user.process_id.#{ _city_id }"] = _process_id if _process_id
session["user.process_id.#{ _city_id }"]
{
"match_details": {
"players": [
{
"account_id": 98887913,
"player_slot": 0,
"hero_id": {
"id": 69,
"name": "Perseverance"
},
@Grandvizir
Grandvizir / _service.md
Created December 28, 2016 13:04 — forked from naholyr/_service.md
Sample /etc/init.d script

Sample service script for debianoids

Look at LSB init scripts for more information.

Usage

Copy to /etc/init.d:

# replace "$YOUR_SERVICE_NAME" with your service's name (whenever it's not enough obvious)