剛剛發現的edge rails中的幾個變化
阿新 • • 發佈:2019-01-25
今天把一個程式切換到edge rails(revision=6688),發現了以下變化:
1. 需要安裝 libopenssl-ruby,否則會有
[code]`const_missing': uninitialized constant ActionController::Base::DEPRECATED_INSTANCE_VARIABLES (NameError)
[/code]
2. URL中的" ; " 變成了“/”
[code]assert_select "a[href=/pages/#{page.id};edit]" [/code]
要改為
[code]
assert_select "a[href=/pages/#{page.id}/edit]" [/code]
3. AR預設對主鍵快取物件例項
在1.2中
[code] ticket = Ticket.find(params[:id])
ticket2 = Ticket.find(params[:id])
ticket.update_attributes(params[:ticket])
ticket.name.should != ticket2.name[/code]
在edge rails中
[code]
ticket = Ticket.find(params[:id])
ticket2 = Ticket.find(params[:id])
ticket.update_attributes(params[:ticket])
ticket.name.should == ticket2.name[/code]
這個變化不用說也清楚,Rails 2.0對效能高度重視。
4. Application::helper_method 不見了
restful_authentication生成的程式碼中
[code] base.send :helper_method, :current_user, :logged_in?[/code]
會出錯,因為找不到helper_method。
1. 需要安裝 libopenssl-ruby,否則會有
[code]`const_missing': uninitialized constant ActionController::Base::DEPRECATED_INSTANCE_VARIABLES (NameError)
[/code]
2. URL中的" ; " 變成了“/”
[code]assert_select "a[href=/pages/#{page.id};edit]" [/code]
要改為
[code]
assert_select "a[href=/pages/#{page.id}/edit]" [/code]
3. AR預設對主鍵快取物件例項
在1.2中
[code] ticket = Ticket.find(params[:id])
ticket2 = Ticket.find(params[:id])
ticket.update_attributes(params[:ticket])
ticket.name.should != ticket2.name[/code]
在edge rails中
[code]
ticket = Ticket.find(params[:id])
ticket2 = Ticket.find(params[:id])
ticket.update_attributes(params[:ticket])
ticket.name.should == ticket2.name[/code]
這個變化不用說也清楚,Rails 2.0對效能高度重視。
4. Application::helper_method 不見了
restful_authentication生成的程式碼中
[code] base.send :helper_method, :current_user, :logged_in?[/code]
會出錯,因為找不到helper_method。