0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 3 years have passed since last update.

rails チュートリアル 4章の軌跡

Posted at

備忘録の用途
1脳のインデックス
2自分ってすごいなと思うため。self esteemが高い人ほど失敗を前向きに捉えるため人生うまくいくらしい。
(引用文献: "DOES HIGH SELF-ESTEEM CAUSE BETTERPERFORMANCE, INTERPERSONAL SUCCESS, HAPPINESS, OR HEALTHIER LIFESTYLES?"
https://www.researchgate.net/publication/296629428_Does_high_self-esteem_cause_better_performance_interpersonal_success_happiness_or_healthier_lifestyles)

まとめ

・nanoを起動した時に驚く⇨ターミナルってそんな動きするんだ!という純粋な驚き
・puts とprintの違い。
・「!!」は「バンバン(bang bang)と読む
・(0..9).to_a を打つと0~9の数字が出てくる
・mapは右側のオブジェクトを左の配列に適用させる潤滑油
・プログラムは自分のうったコードの通りに動く。

おまけ
演習問題の解答達。合っているかは分からない。
・hashの理解

>> spain = {}
=> {}
>> spain[:uno]= "one"
=> "one"
>> spain[:two]= "dos"                                              
=> "dos"
>> spain[:three]= "tres"                                           
=> "tres"
>> spain
=> {:uno=>"one", :two=>"dos", :three=>"tres"}
>> spain.each do |key,value|
?> puts "'#{key}'の英語は'#{value}'です"
>> end
'uno'の英語は'one'です
'two'の英語は'dos'です
'three'の英語は'tres'です
=> {:uno=>"one", :two=>"dos", :three=>"tres"}
>> params =["person1","person2","person3"]
=> ["person1", "person2", "person3"]
>> params[0]={first:"すばる",last:"だーよ"}
=> {:first=>"すばる", :last=>"だーよ"}
>> params[1]={first:"滑る",last:"ヨーダ"}
=> {:first=>"滑る", :last=>"ヨーダ"}
>> params[2]={first:"スボル",last:"の"}
=> {:first=>"スボル", :last=>"の"}
>> inde[:father]=params[1]
>> aa[:child] = params[2]                                         
=> {:first=>"スボル", :last=>"の"}
>> aa[:child][:first]
=> "スボル"
>> aa[:child][:first] = params[2][:first]
=> "スボル"
>> aa[:child][:first] == params[2][:first]
=> true

・ランダム数字のパスワード作成

>>  user ={name:"おくとむ",email:"okutom@aaa",password:"okutomm"}
=> {:name=>"おくとむ", :email=>"okutom@aaa", :password=>"okutomm"}
>> user[:password] = ('a'..'z').to_a.shuffle[0..16].join
=> "webrovxlfymqatigh"
>> user
=> {:name=>"おくとむ", :email=>"okutom@aaa", :password=>"webrovxlfymqatigh"}
>> 

・joinの失敗

 params ={}
>> params = "person1"
=> "person1"
"person1person2"
>> params << "person3"
=> "person1person2person3"
>> params.join(',') ⇨これは出来ない
Traceback (most recent call last):
        1: from (irb):7

Range.newはよく分かっていない。

>> Range.new(0,8)
=> 0..8
>> a = (0..8).to_a
=> [0, 1, 2, 3, 4, 5, 6, 7, 8]
>> a ==  Range.new(0,8)
=> false

最後はもちろんtestとherokuデプロイを忘れずに。

$rails test
Finished in 1.32019s
4 tests, 12 assertions, 0 failures, 0 errors, 0 skips
$git push
$git heroku push
remote: Verifying deploy... done.

参考文献:
"DOES HIGH SELF-ESTEEM CAUSE BETTERPERFORMANCE, INTERPERSONAL SUCCESS, HAPPINESS, OR HEALTHIER LIFESTYLES?"
https://www.researchgate.net/publication/296629428_Does_high_self-esteem_cause_better_performance_interpersonal_success_happiness_or_healthier_lifestyles

rails チュートリアル:https://railstutorial.jp/

0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?