class User < ActiveRecord::Base
extend Enumerize
enumerize :sex, :in => [:male, :female], scope: true
enumerize :status, :in => { active: 1, blocked: 2 }, scope: :having_status
end
User.with_sex(:female)
# SELECT "users".* FROM "users" WHERE "users"."sex" IN ('female')
User.without_sex(:male)
# SELECT "users".* FROM "users" WHERE "users"."sex" NOT IN ('male')
User.having_status(:blocked).with_sex(:male, :female)
# SELECT "users".* FROM "users" WHERE "users"."status" IN (2) AND "users"."sex" IN ('male', 'female')
Oracle, MySQL 等、DUALが使用可能なデータベースでは、次の様に記述すれば簡単に確認ができる。
SELECT * FROM (
SELECT 1 id, NULL a, NULL b FROM DUAL UNION
SELECT 2 id, NULL a, 2222 b FROM DUAL UNION
SELECT 3 id, 1111 a, 2222 b FROM DUAL UNION
SELECT 4 id, 1111 a, 1111 b FROM DUAL
) t
WHERE /* ここに条件を記載 */;
class PagedownInput < SimpleForm::Inputs::TextInput
def input(wrapper_options)
out = "\n"
html_options = input_html_options.merge(class: 'wmd-input', id: "wmd-input-#{attribute_name}")
out << "#{@builder.text_area(attribute_name, merge_options(html_options, wrapper_options)) }"
if input_html_options[:preview]
out << ""
end
out.html_safe
end
private
def merge_options(html_opts, wrapper_opts)
html_opts.merge(wrapper_opts) { |_key, first, second| first + ' ' + second }
end
end
Cannot load JDBC driver class 'oracle.jdbc.OracleDriver'
java.lang.StackOverflowError
at java.util.Stack.empty(Stack.java:96)
at sun.misc.URLClassPath.getLoader(URLClassPath.java:283)
at sun.misc.URLClassPath.getResource(URLClassPath.java:168)
at java.net.URLClassLoader$1.run(URLClassLoader.java:194)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(URLClassLoader.java:190)
at sun.misc.Launcher$ExtClassLoader.findClass(Launcher.java:229)
at java.lang.ClassLoader.loadClass(ClassLoader.java:306)
at java.lang.ClassLoader.loadClass(ClassLoader.java:295)
at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:301)
at java.lang.ClassLoader.loadClass(ClassLoader.java:247)
at org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1595)
...
$ svn up
svn: The path '.' appears to be part of a Subversion 1.7 or greater
working copy. Please upgrade your Subversion client to use this
working copy.
参照 wget http://sourceforge.net/projects/s3tools/files/s3cmd/1.5.2/s3cmd-1.5.2.tar.gz tar zxvf s3cmd-1.5.2.tar.gz cd s3cmd-1.5.2 python setup.py install yum -y install python-dateutil s3cmd –version =>s3cmd version 1.5.2
s3cmd設定
s3cmd –configure Access Key:管理画面でみたAPI Key Secret Key:管理画面でみたSecret Key Default Region [US]:ap-northeast-1 ←東京らしい Encryption password: Path to GPG program [/bin/gpg]: Use HTTPS protocol [No]:Yes HTTP Proxy server name: Test access with supplied credentials? [Y/n] n Save settings? [y/N] y Configuration saved to ‘/root/.s3cfg’
s3cmdアカウント設定
cd ~ vim .s3cfg ————— host_base = 管理画面エンドポイント host_bucket = %(bucket)s.管理画面エンドポイント signature_v2 = True —————
コマンド実行
s3cmd ls バケット参照 s3cmd setacl –acl-public s3://バケット名/オブジェクト名 コマンド参照