# Should I have private and public controllers?

**URL:** <https://www.ruby-forum.com/t/should-i-have-private-and-public-controllers/92597>\
**Category:** Rails\
**Created:** [April 21, 2007, 9:31am UTC](https://www.ruby-forum.com/t/should-i-have-private-and-public-controllers/92597 "2007-04-21T09:31:41Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![liquid](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/l/47e85d/32.png) [@liquid](https://www.ruby-forum.com/u/liquid)\
**Post date:** [April 21, 2007, 9:31am UTC](https://www.ruby-forum.com/t/should-i-have-private-and-public-controllers/92597/1 "2007-04-21T09:31:41Z")

</div>

I have a resource where there can be private or public items.

If an item is public then no login is required to view, but if it’s  
private then only the owner should be able to see it.

I’ve thought that I will just have two controllers. One for when  
people are logged in and checks for privacy and stuff, and another  
that just does public access. Is this ok or is there a problem  
because there will effectively be two URL’s to the one resource?

Anyone has a thougt on this?

Cheers  
Daniel

---

<div class="post-metadata">

**Author:** ![liquid](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/l/47e85d/32.png) [@liquid](https://www.ruby-forum.com/u/liquid)\
**Post date:** [April 21, 2007, 10:17pm UTC](https://www.ruby-forum.com/t/should-i-have-private-and-public-controllers/92597/2 "2007-04-21T22:17:54Z")

</div>

Hi, you should simply use an authentication system like  
acts\_as\_authenticated to protect the relevant areas of your site.

Good luck,

-Conrad

---

<div class="post-metadata">

**Author:** ![liquid](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/l/47e85d/32.png) [@liquid](https://www.ruby-forum.com/u/liquid)\
**Post date:** [April 23, 2007, 1:18am UTC](https://www.ruby-forum.com/t/should-i-have-private-and-public-controllers/92597/3 "2007-04-23T01:18:05Z")

</div>

On 4/22/07, Conrad T. [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) wrote:

> Hi, you should simply use an authentication system like  
> acts\_as\_authenticated to protect the relevant areas of your site.
> 
> Good luck,
> 
> -Conrad

Hi Conrad,

I use the restful\_authentication plugin. The items are model instances  
and  
so are not constrained by permissions on controllers. Hence the  
question.

The owner of items may have a collection of public and a collection of  
private items. Another person, or an anonymous user should be able to  
access these public items. whether logged in or not.

I think I’m going to go for two controllers with different layouts.  
That  
way I can have public actions on the public layout and logged in actions  
in  
the private layout, and the logic is kept reasonably seperate.

Thanx for your input though.

Cheers
