Welcome to the Treehouse Community

The Treehouse Community is a meeting place for developers, designers, and programmers of all backgrounds and skill levels to get support. Collaborate here on code errors or bugs that you need feedback on, or asking for an extra set of eyes on your latest project. Join thousands of Treehouse students and alumni in the community today. (Note: Only Treehouse students can comment or ask questions, but non-students are welcome to browse our conversations.)

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and a supportive community. Start your free trial today.

Ruby

Public vs. Private Status'

I've been working on extending the Treebook application and one of the concepts I've added is a flag on the status to either make the status a 'public' i.e. seen by other users or 'private' status only seen by the current user.

Right now I make this check in the status index view with this code

    <% if status.visable == true || status.user_id == current_user.id %>

I'm pretty sure this violates the DRY principle though as there maybe other pages where you want to a list of status so I would assume you that you would want to move this to a method and call that method in the status controller in the index method however, after many hours on Google I haven't found a way that works.

1 Answer

Brandon Barrette
Brandon Barrette
20,485 Points

What's your question? I'm not sure I understand the issue you're having.