I have a User model that contains information such as username, email, hometown, etc. When the user is logged in, he can edit any of his information via the show page (/users/723, for example).
I’d like to have a “public” version of this page that can be viewed by someone that’s not logged in or by someone that’s logged in as someone else. It would have varying levels of information about the user and not have any of the links to edit information.
What’s the cleanest way to properly show the three different versions of this page?
Addendum.
I am currently using authlogic for authentication and acl9 for access control. However, I don’t see this as a question of authentication and authorization. I think it’s a question of controller/view design. Whether the user is logged in or owns the information is incidental. If you wanted to display Widgets in three different manners based on some session state, I would think you’d be able to use the answer to this question.
There are tons of ways of doing this, and I do not think there is a cleanest way.
I would probably break the page into partials, one partial for each grouping of information you need.
Then you could have variables control which partials get rendered.
For example (in HAML):
For the real simple stuff you could inline the if (and not have a partial)
Alternatively, if stuff is getting out of hand, you can have different views for each “show” page.