How to pass argument to delegate method in Rails
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试): 由 翻译 强力驱动 问题: I would like to have a Dashboard to display summary of multiple models, and I implemented it using Presenter without its own data. I use an ActiveModel class (without data table): class Dashboard attr_accessor : user_id def initialize ( id ) self . user_id = id end delegate : username , : password , : to => : user delegate : address , : to => : account delegate : friends , : to => : friendship end By delegate, I want to be able to call Dashboard.address and get back Account.find_by_user_id(Dashboard.user_id).address . If Dashboard