Skip to content

Instantly share code, notes, and snippets.

View YumaInaura's full-sized avatar

いなうらゆうま ( 稲浦悠馬 ) YumaInaura

View GitHub Profile
@YumaInaura
YumaInaura / create_example.rb
Created December 7, 2015 04:48
Rails | migration で t.timestamp が動かない? ref: http://qiita.com/Yinaura/items/705d3d26710a31d2a66e
class CreateExample < ActiveRecord::Migration
def change
create_table :example do |t|
t.string :requester
- t.timestamp
+ t.timestamps
end
end
end
@YumaInaura
YumaInaura / example.rb
Last active December 8, 2015 09:23
Rails | モデルの validate 文が効かない? ref: http://qiita.com/Yinaura/items/c9e7e0629165ee0032f7
class Example < ActiveRecord::Base
- validate :user_id, presence: true
+ validates :user_id, presence: true
end
@YumaInaura
YumaInaura / file1.txt
Last active December 9, 2015 09:33
bash | 正規表現で連続したスペースを削除する ref: http://qiita.com/Yinaura/items/aa90473cb4a876e4988f
abc
abc
abc
abc
@YumaInaura
YumaInaura / test.rb
Created December 10, 2015 04:12
Rails | ActiveDecorator を View 以外で使う方法 ( Rspec テストなど ) ref: http://qiita.com/Yinaura/items/2ac43179b77c5685430f
ActiveDecorator::Decorator.instance.decorate(ExampleClass.first).decorated_name
# => '*J*o*h*n*'
@YumaInaura
YumaInaura / file0.txt
Created December 10, 2015 07:57
Ruby | String には grep じゃなく match ref: http://qiita.com/Yinaura/items/0eb78d64f788fc4a35ce
'ABC'.grep /B/
# => NoMethodError: undefined method `grep'
@YumaInaura
YumaInaura / file1.txt
Last active December 15, 2015 01:08
Rspec | should と is_expected では subject と let が逆の順番で走る ref: http://qiita.com/Yinaura/items/048494244fd390025ac3
when Rspec 2
"LET"
"SUBJECT"
should eq "example"
when Rspec 3
"SUBJECT"
"LET"
should eq "example"
@YumaInaura
YumaInaura / file0.txt
Last active December 15, 2015 04:04
Ruby | attr_accessor + initialize でアクセサ変数に代入できない時 ref: http://qiita.com/Yinaura/items/02c8bd7bd87cfa64ce6c
class Book
attr_accessor :price
def initialize
price = 1080
end
end
@YumaInaura
YumaInaura / file0.sql
Last active December 18, 2015 02:53
MySQL | 英数字以外とアンダーバー 以外をデータベース名 / テーブル名に使う時はバッククォートで囲う ref: http://qiita.com/Yinaura/items/823c12fc1fd36bd18b63
mysql> CREATE DATABASE e-x-a-m-p-l-e;
@YumaInaura
YumaInaura / file0.txt
Last active December 18, 2015 05:11
Git | commit --amend を途中で取り消しする方法 (コミットメッセージ入力中のキャンセル) ref: http://qiita.com/Yinaura/items/39f3a688f591f2b175dd
Fix you brain
# Please enter the commit message for your changes. Lines starting
# with '#' will be ignored, and an empty message aborts the commit.
# ...
@YumaInaura
YumaInaura / .gitconfig
Last active December 18, 2015 06:38
Git | 現在のブランチルートから rebase -i する方法 ref: http://qiita.com/Yinaura/items/302c8d6b9f0f4806d812
[alias]
branch-root = merge-base master HEAD