何回も調べてしまう attribute? の定義箇所
ここを見ると query methods と書かれているので、 https://github.com/rails/rails/blob/master/activerecord/lib/active_record/base.rb
# == Attribute query methods # # In addition to the basic accessors, query methods are also automatically available on the Active Record object. # Query methods allow you to test whether an attribute value is present. # Additionally, when dealing with numeric values, a query method will return false if the value is zero. # # For example, an Active Record User with the <tt>name</tt> attribute has a <tt>name?</tt> method that you can call # to determine whether the user has a name: # # user = User.new(name: "David") # user.name? # => true # # anonymous = User.new(name: "") # anonymous.name? # => false
ここを見に行くとそれがある https://github.com/rails/rails/blob/master/activerecord/lib/active_record/attribute_methods/query.rb
Rails の save, destroy は自動的に transaction でラップされる
save and destroy are automatically wrapped in a transaction Both save and destroy come wrapped in a transaction that ensures that whatever you do in validations or callbacks will happen under its protected cover. So you can use validations to check for values that the transaction depends on or you can raise exceptions in the callbacks to rollback, including after_* callbacks. As a consequence changes to the database are not seen outside your connection until the operation is complete. For example, if you try to update the index of a search engine in after_save the indexer won't see the updated record. The after_commit callback is the only one that is triggered once the update is committed. See below.
11/16 気になった記事
- JavaScript - 手書きしたほうが速いメソッドと疎な配列 - Qiita
- Remove not needed
NATIVE_DATABASE_TYPES
entries by kamipo · Pull Request #22302 · rails/rails- kamipoさんコミット
- オブジェクト指向UX – ユーザーのメンタルモデルの”オブジェクト”からデザインする | デザイン | POSTD
- Macを凌ぐパワフルさ! iPad Proのベンチマークが凄い : ギズモード・ジャパン
- Struct and OpenStruct will be able to chain the Hash#dig, Array#dig by kachick · Pull Request #1097 · ruby/ruby
- どういう場面で有効なんだろう
NodeFestに来ていたカットマルちゃんと今日ランチを食べたんだけど、そこで言ってたのは
1. “bower is dead“
2. “npm v2 は LTS で 2018/4まで残る”
3. “gulpじゃなくてnpm-scriptにするのは規模次第”
っていう話をしました
— Yosuke FURUKAWA (@yosuke_furukawa) November 16, 2015
とりあえず、 bower is dead なのは共通認識なのでもう使わないほうが良い。
— Yosuke FURUKAWA (@yosuke_furukawa) November 16, 2015