Michael Hartle compares books between Rails 3.0 and Rails 3.2

I am learning Ruby on Rails from a book by Michael Hartle. I really like this letter, structured and understandable. However, I have a question about section 3.3 differences between Rails 3.0 and Rails 3.2:

  • PagesController becomes StaticPagesController
  • @Title no longer initialized in the controller, but on every page
  • The variable is @Titleinitialized using the "provide" function and is used through the "yield" function instead of simply pasting<%= @title %>

Is it for learning reasons, or is it an updated best practice for developing RoR?

+5
source share
1 answer

The PagesController becomes StaticPagesController

. PagesController . , , (?).

@Title ,

/. , - MVC?

@Title "" "yield" <% = @title% >

, .

, -, , , .

provide content_for : http://api.rubyonrails.org/classes/ActionController/Streaming.html#module-ActionController::Streaming-label-Communication+between+layout+and+template

, Rails 3.2 ( provide, stream Rails 3.1).

+16

All Articles