Skip to content

Instantly share code, notes, and snippets.

# How to not use 'before_action :authorize_user!' in controllers
devise_for :users
root to: "home#index"
# this route for signed in users and guests
resources :games, only: [:show]
# create routes with redirect to sign_in for guests
authenticate(:user) do

Usage

require tp_logger in spec_helper and run TPLogger.start The main goal of early start is to catch class definitions. Therefore it is important to start it before loading rails environment and initializers.

require 'tp_logger'
TPLogger.start(filter: 'project_folder_name', dump_path: 'tplogger.csv')
path = require 'path'
webpack = require 'webpack'
exec = require 'exec-sync'
gemDir = (name) ->
exec('bundle show ' + name)
refileDir = path.join(gemDir('refile'), 'app/assets/javascripts')
jqueryRailsDir = path.join(gemDir('jquery-rails'), 'vendor/assets/javascripts')
require('coffee-script/register');
module.exports = require('./webpack.config.coffee');
require 'rails_helper'
RSpec.describe UserReport do
# Jun | Aug | Sep
#-----|--|--|--|--|--|--|--> time
# * | * * |
#
# Short periods - weeks
# Stars - timelogs
class Array
undef :each
def each
return to_enum(__callee__) unless block_given?
size.times do |i|
yield self[i]
end
end
@cutalion
cutalion / create_settings.rb
Last active November 18, 2015 09:04
Settings model for rails
class CreateSettings < ActiveRecord::Migration
def change
create_table :settings do |t|
t.string :key
t.string :human_name
t.text :value
t.timestamps null: false
end
end
end
Ничейщик = Class.new do
def self.name; "Ничейщик"; end
def self.inspect; "Ничейщик"; end
def self.Ничейщик; Ничейщик; end
def whoami?
self.class.name
end
@cutalion
cutalion / .rspec
Last active April 7, 2016 22:32
Arduino formatter for rspec
--color
--require spec_helper
--format Fuubar
--format ArduinoFormatter
N = 10_000
matched1 = 0
matched2 = 0
N.times do
seq = [1, 0, 0].shuffle
guess = rand(3)
matched1 += 1 if seq[guess].eql?(1)