Upgrade to Pro — share decks privately, control downloads, hide ads and more …

20150625_SpeeeTeckParty

 20150625_SpeeeTeckParty

6/25に開催された、SpeeeTeckPartyで話したときに資料です。

Tatsuya Sasaki

June 30, 2015
Tweet

More Decks by Tatsuya Sasaki

Other Decks in Technology

Transcript

  1. > hash = Hash.new { |h,k| h[k] = {} }

    => {} > hash[:foo] => {} # nil͡Όͳ͍ʂ
  2. > hash = Hash.new { |h,k| h[k] = {} }

    => {} > hash[:foo] => {} # nil͡Όͳ͍ʂ > hash[:foo][:bar] => nil > hash[:foo][:bar] = 1 => 1 > hash => { foo: { bar: 1 } }
  3. class Group before_save :set_default_name_if_need def post(comment); end end ! class

    Message before_save :set_default_name_if_need def post(comment); end end ಉ͡Α͏ͳॲཧ͕͋Δ৔߹
  4. $ rails console —sandbox > user = User.first => #<User

    id: 1, name: "sasata299", like: "karaage"> > user.like = "sushi" => "sushi" > u.save! => true
  5. $ rails console —sandbox > user = User.first => #<User

    id: 1, name: "sasata299", like: "karaage"> > user.like = "sushi" => "sushi" > u.save! => true > user = User.first => #<User id: 1, name: "sasata299", like: "sushi">
  6. $ rails console > user = User.first => #<User id:

    1, name: "sasata299", like: “karaage"> ࠶౓DPOTPMFΛ։͘ͱSPMMCBDL͞ΕͯΔ
  7. $ rails console > user = User.first => #<User id:

    1, name: "sasata299", like: “karaage"> > _ => #<User id: 1, name: "sasata299", like: “karaage"> ͪͳΈʹΞϯμʔείΞศརͰ͢
  8. user system total real select 16.290000 0.760000 17.050000 ( 20.753481)

    pluck 4.350000 0.590000 4.940000 ( 6.712115) ഒҎ্଎͍ͧʂ
  9. Started POST "/users" Processing by UsersController#create as HTML Parameters: {"email"=>"[email protected]",

    “password"=>"secret-value", “credit_card_number"=>"1111-2222-3333-4444"}
  10. Food.create! <#Food id: 1, type: "Food", …> ! 2.times {

    Drink.create! } <#Drink id: 2, type: "Drink", …> <#Drink id: 3, type: "Drink", …>
  11. mysql> SELECT id, type FROM products; ! +----+-------+ | id

    | type | +----+-------+ | 1 | Food | | 2 | Drink | | 3 | Drink | +----+-------+
  12. Food.all [#<Food id: 1, type: "Food", …>] ! Drink.all [#<Drink

    id: 2, type: "Drink", …>, #<Drink id: 3, type: "Drink", …>] ! Product.all [#<Food id: 1, type: "Food", …>, #<Drink id: 2, type: "Drink", …>, #<Drink id: 3, type: "Drink", …>]
  13. class Bar include Foo end ! p Bar.ancestors # [Bar,

    Foo, Object, …] #BSΫϥε͕༏ઌ͞ΕΔ
  14. class Bar prepend Foo end ! p Bar.ancestors # [Foo,

    Bar, Object, …] 'PPϞδϡʔϧ͕༏ઌ͞ΕΔ