欢迎来到天天文库
浏览记录
ID:41220255
大小:684.55 KB
页数:130页
时间:2019-08-19
《Rails 4 Countdown》由会员上传分享,免费在线阅读,更多相关内容在学术论文-天天文库。
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_findersWhy?hashsyntax#PreviousVersionsPost.find(:all,conditions:{published_on:2.weeks.ago},limit:5)#Rails4Post.where(:published_on:2.weeks.ago).limit(5)find_all_by_*#PreviousVersionsTeam.find_all_by_name('JusticeLeague')#Rails4Team.where(name:'Justic
4、eLeague')find_last_by_*#PreviousVersionsRails3:Team.find_last_by_name('JusticeLeague')#Rails4Rails4:Team.where(name:'JusticeLeague').lastfind_or_create_by_*#PreviousVersionsTeam.find_or_create_by_name('JusticeLeague')#Rails4Team.where(name:'JusticeLeague').first_or_createfind_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,andsetsthepermittedattributetotrue8、.AvailableNow!1.Addthestrong_parametersgemtoyou
7、_params)...endprivatedefperson_paramsparams.require(:person).permit(:name,:age)endendrequire(:key)FetchesthekeyoutofthehashandraisesaActionController::ParameterMissingerrorifit'smissing.permit(keys)Selectsonlythepassedkeysoutoftheparametershash,andsetsthepermittedattributetotrue
8、.AvailableNow!1.Addthestrong_parametersgemtoyou
此文档下载收益归作者所有