CentOS release 6.9
- MySQL
5.1.62-log
- CkePHP
2.3.10
- PHP
5.3.3 (cli) (built: Mar 22 2017 12:27:09)
- Apache
- vhosts
- そのほか
- jQuery mobile使われてた
This file contains 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
# app/models/concerns/varying_array_parsable.rb | |
module VaryingArrayParsable | |
extend ActiveSupport::Concern | |
class VaryingArrayParser | |
# @see {https://github.com/rails/rails/blob/4-2-stable/activerecord/lib/active_record/connection_adapters/postgresql/oid/array.rb} | |
# Loads pg_array_parser if available. String parsing can be | |
# performed quicker by a native extension, which will not create | |
# a large amount of Ruby objects that will need to be garbage | |
# collected. pg_array_parser has a C and Java extension |
This file contains 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 HashWithDestructiveMethods < Hash | |
class << self | |
def [](*args) | |
new.merge!(Hash[*args]) | |
end | |
end | |
alias_method :regular_writer, :[]= unless method_defined?(:regular_writer) | |
def initialize(constructor = {}) |
This file contains 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
FROM ruby:2.6.3-alpine as base | |
LABEL maintainer="nagait84 <[email protected]>" | |
# ビルド時の作業ディレクトリ | |
WORKDIR /app | |
# bundler インストールパスの指定 | |
ENV BUNDLE_APP_CONFIG /app/.bundle | |
# Railsのログは標準出力に流す |
This file contains 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
# @note Concern扱いではなく、#extendingとして使用 | |
module DmlSanitizable | |
# PostgreSQL使用時に、MySQLの `ORDER BY FIELD()` 関数と同じ挙動をさせる | |
# @example | |
# models = Model.all.extending(DmlSanitizable) | |
# models.order_by_field(:color, ['緑', '紫', '赤', '青', '黄'], :desc) | |
# # => [#<Model color: '黄'>, #<Model color: '青'>, #<Model color: '赤'>, ...] | |
# @param column [Symbol] | |
# @param custom_list [Array] 並び替えたい値の順序 | |
# @param sort_order [Symbol(:asc), Symbol(:desc)] (:asc) 昇順or降順 |
This file contains 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 ExamplesController < ApplicationController | |
# 例えばこんな感じに使用する | |
# ユーザーによる全角での金額入力やカンマ区切りの金額入力、前後の無駄なスペースなどをよしなに置き換える | |
before_action( | |
lambda { | |
hankaku_and_strip_params(food: [:price, :price_down], drink: [:price, :price_down]) | |
}, | |
only: [:create, :update] | |
) |