資源描述:
《Rails 4 Countdown》由會員上傳分享,免費在線閱讀,更多相關內(nèi)容在學術論文-天天文庫。
1、Rails4CountdownI’mRida@ridaIworkhereI’mKevin@kfaustinoIworkhereDeprecationsvendor/pluginsActiveRecordSessionStoreactiverecord-session_storeWhy?Remove#config/initializers/session_store.rbExample::Application.config.session_store:active_record_storeReplaceWith#config/initializers/
2、session_store.rbExample::Application.config.session_store:encrypted_cookie_store,key:'_example_session'UseaKey-ValueStorePage&ActionCachingactionpack-page_cachingactionpack-action_cachingWhy?UseRussianDollCachingObserversrails-observersWhy?ActiveResourceactiveresourceWhy?Dynamic
3、Findersactiverecord-deprecated_?ndersWhy?hashsyntax#PreviousVersionsPost.find(:all,conditions:{published_on:2.weeks.ago},limit:5)#Rails4Post.where(:published_on:2.weeks.ago).limit(5)?nd_all_by_*#PreviousVersionsTeam.find_all_by_name('JusticeLeague')#Rails4Team.where(name:'Justic
4、eLeague')?nd_last_by_*#PreviousVersionsRails3:Team.find_last_by_name('JusticeLeague')#Rails4Rails4:Team.where(name:'JusticeLeague').last?nd_or_create_by_*#PreviousVersionsTeam.find_or_create_by_name('JusticeLeague')#Rails4Team.where(name:'JusticeLeague').first_or_create?nd_or_in
5、itialize_by#PreviousVersionsTeam.find_or_initialize_by_name('JusticeLeague')#Rails4Team.where(name:'JusticeLeague').first_or_initializescoped_by_*#PreviousVersionsTeam.scoped_by_name('JusticeLeague')#Rails4Team.where(name:'JusticeLeague')ProtectedAttributesprotected_attributesWh
6、y?StrongParametersRails3WayclassPeopleController7、_params)...endprivatedefperson_paramsparams.require(:person).permit(:name,:age)endendrequire(:key)FetchesthekeyoutofthehashandraisesaActionController::ParameterMissingerrorifit'smissing.permit(keys)Selectsonlythepassedkeysoutoftheparametershash,andsetsthepermittedattributetotrue
8、.AvailableNow!1.Addthestrong_parametersgemtoyou