What would your thoughts on using decorators to show/hide certain information based on the current user's permissions (eg. with CanCan) - by doing something like:
ruby
if can? :read, model
h.link_to model.email, "mailto:#{model.email}"else
content_tag :p, "Not listed", :class => "none"end
within the decorator? A use case might be a member directory where non-members can only see members name but logged-in members can see each others email addresses.
Maybe it's a bit of an edge case? Do you think it would appropriate to put authorisation logic in a decorator?
You might be interested in this gem I made called CSV shaper that allows you to create CSV output using a really nice Ruby DSL.
https://github.com/paulspringett/csv_shaper
Thanks for another great episode Ryan!
What would your thoughts on using decorators to show/hide certain information based on the current user's permissions (eg. with CanCan) - by doing something like:
within the decorator? A use case might be a member directory where non-members can only see members name but logged-in members can see each others email addresses.
Maybe it's a bit of an edge case? Do you think it would appropriate to put authorisation logic in a decorator?