Rails Tutorial Ch.5 ~my study record~

これまで日本語のチュートリアルを読んでいたのですが、最近読む論文も英語、授業も英語、オンラインで受ける授業や見るドキュメンタリーも英語、なのでプログラミングの勉強も英語でやる方がモチベーションが高く保てそうだということで、rails tutorialの英語バージョンを読み、それを英語でまとめようかと思います。乱れあるかもしれませんが勉強ですね。

first, i should put the header tag between body tag. header tag should go at the top of the page.header tag has three CSS classes,

all html elements should have class or id. The difference between class and id is how many times we can use in CSS. Class can be used for several times, on the other hand, id can be used just once. navbar classes have special meaning for Bootstrap.

in the next step, i put this code. link_to is equal to a tag, that link to other pages. first argument is the text, second is the URL, and third one is option hash.

the final part is like this. as i learned the previous section, yield method inserts the contents of each page into the site layout.

after writing HTML, i should use the bootstrap to layout the site, later on, i use CSS. like this,

next, i learned the partial. partial is effective to divide the code for seeing easily. in this case, i move the header from application.html.erb into _header.html.erb. for this, i should make use of the render method:

the effect of this line is to look for a file called layouts/_header, and insert the result into the view.underscore(_) means the partial.

in the next section, textbook focused on the “asset pipeline”. Rails asset pipeline uses three directories, app/assets, lib/assets, vendor/assets. each directory has three subdirectory, “images/javascripts/stylesheets”. first, we will see the app/assets/stylesheets for understanding the css.

asset pipeline enables us to be efficient, productive. because that is well formated, but any css file can be gathered into the application.css. So, it is really speedy.

rails conventionally uses the named routes, like,

umm, its difficult to explain in English for me, but i can totally understand this chapter.


  • このエントリーをはてなブックマークに追加