This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require 'bundler/setup' | |
require 'active_support/all' | |
require 'rack' | |
require 'rack/test' | |
require 'action_controller/metal/strong_parameters' | |
params = ActionController::Parameters.new({ | |
person: { | |
title: "kir", | |
collects: "shatrov" |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require 'bundler/setup' | |
require 'active_record' | |
ActiveRecord::Base.establish_connection(adapter: 'sqlite3', database: ':memory:') | |
ActiveRecord::Schema.define do | |
create_table "users" do |t| | |
t.string "name" | |
end | |
end | |
class User < ActiveRecord::Base |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
TaxLineSchema = Dry::Validation.Form do | |
optional(:title) | |
optional(:price) | |
optional(:rate) | |
optional(:position) | |
optional(:zone) | |
optional(:source) | |
end | |
OrderSchema = Dry::Validation.Form do |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require 'bundler/setup' | |
require 'active_record' | |
ActiveRecord::Base.establish_connection(adapter: 'sqlite3', database: ':memory:') | |
ActiveRecord::Schema.define do | |
create_table "users" do |t| | |
t.string "name" | |
end | |
end | |
class User < ActiveRecord::Base;end |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require 'bundler/setup' | |
require 'active_record' | |
ActiveRecord::Base.establish_connection(adapter: 'sqlite3', database: ':memory:') | |
ActiveRecord::Base.logger = Logger.new(STDOUT) | |
ActiveRecord::Schema.define do | |
create_table "users" do |t| | |
t.string "name" | |
end | |
end |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require File.expand_path('../load_paths', __FILE__) | |
require 'active_record' | |
ActiveRecord::Base.establish_connection(adapter: 'sqlite3', database: ':memory:') | |
ActiveRecord::Base.logger = Logger.new(STDOUT) | |
ActiveRecord::Schema.define do | |
create_table "users" do |t| | |
t.string "name" | |
t.integer "posts_count", default: 0, null: false | |
end |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class MyRelation | |
def initialize(page) | |
@page = page.to_i | |
@limit = 10 | |
end | |
def current_page | |
@page | |
end |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# this is a dirty implementation of logger that | |
# compiles AR queries with trace into /last_request_log.html | |
# the snippet is useful when optimizing performance of the endpoint | |
class QueryLogSubscriber < ActiveSupport::LogSubscriber | |
TRACE_LEVEL = :app | |
LINES = 5 | |
IGNORE_CACHED_QUERIES = false | |
def initialize |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# this is a dirty implementation of logger that | |
# compiles AR queries with trace into /last_request_log.html | |
# the snippet is useful when optimizing performance of the endpoint | |
class QueryLogSubscriber < ActiveSupport::LogSubscriber | |
TRACE_LEVEL = :app | |
LINES = 5 | |
IGNORE_CACHED_QUERIES = false | |
def initialize |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$ npm install | |
npm WARN package.json [email protected] No bin file found at lib/cli.js | |
> [email protected] install /Users/kir/Projects/opensource/rubysauna/showbox/node_modules/browser-sync/node_modules/socket.io/node_modules/engine.io/node_modules/ws/node_modules/utf-8-validate | |
> node-gyp rebuild | |
xcode-select: error: tool 'xcodebuild' requires Xcode, but active developer directory '/Library/Developer/CommandLineTools' is a command line tools instance | |
xcode-select: error: tool 'xcodebuild' requires Xcode, but active developer directory '/Library/Developer/CommandLineTools' is a command line tools instance |