Rails view decorator: Draper VS ActiveDecorator

rainchen · December 12, 2012 · 2775 hits

前序: Draper (https://github.com/drapergem/draper) 和 ActiveDecorator (https://github.com/amatsuda/active_decoratorview) 一样都是用于偶合 helper 和 model 的工具。

铺垫: 一个比较常见的场景:显示用户头像并连接到用户主页,在普通的 view 代码中需要使用很长的一段: <%= link_to image_tag(user.avatar.url), user_profile_path(user) %>

... 通过使用 view decorator 简化为: <%= user.avatar_tag %> <%= user.name_with_gender %>

文长详见: http://hi.baidu.com/rainchen/item/7e63a5cfbfe02abb0c0a7be7

No Reply at the moment.
You need to Sign in before reply, if you don't have an account, please Sign up first.