# Private Actions that have Views aren't that private

**URL:** <https://www.ruby-forum.com/t/private-actions-that-have-views-arent-that-private/116618>\
**Category:** Rails\
**Created:** [October 8, 2007, 1:06am UTC](https://www.ruby-forum.com/t/private-actions-that-have-views-arent-that-private/116618 "2007-10-08T01:06:26Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![Onildo](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/o/c5a1d2/32.png) [@Onildo](https://www.ruby-forum.com/u/Onildo)\
**Post date:** [October 8, 2007, 1:06am UTC](https://www.ruby-forum.com/t/private-actions-that-have-views-arent-that-private/116618/1 "2007-10-08T01:06:26Z")

</div>

Hello

If a certain action in a certain controller is private it should  
return an “Unknown action” error if you type its path in the browser.  
But if it has a corresponding view, the browser actually shows the  
view. Why is that so?

---

<div class="post-metadata">

**Author:** ![Onildo](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/o/c5a1d2/32.png) [@Onildo](https://www.ruby-forum.com/u/Onildo)\
**Post date:** [October 8, 2007, 2:06am UTC](https://www.ruby-forum.com/t/private-actions-that-have-views-arent-that-private/116618/2 "2007-10-08T02:06:46Z")

</div>

On 8 Oct 2007, at 00:05, Onildo wrote:

> Hello
> 
> If a certain action in a certain controller is private it should  
> return an “Unknown action” error if you type its path in the browser.  
> But if it has a corresponding view, the browser actually shows the  
> view. Why is that so?

Because ActionController basically does

if self.class.public\_methods.include?(method)  
#perform the action  
elsif template\_exists?(method)  
#render template  
else  
raise ‘Unknown action’  
end

Fred

---

<div class="post-metadata">

**Author:** ![Onildo](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/o/c5a1d2/32.png) [@Onildo](https://www.ruby-forum.com/u/Onildo)\
**Post date:** [October 8, 2007, 5:55am UTC](https://www.ruby-forum.com/t/private-actions-that-have-views-arent-that-private/116618/3 "2007-10-08T05:55:23Z")

</div>

Yup. This is also true if there’s a template without a controller  
method either.

–Jeremy

On 10/7/07, Onildo [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) wrote:

> 

–  
[http://www.jeremymcanally.com/](http://www.jeremymcanally.com/)

My books:  
Ruby in Practice

> **[Ruby in Practice](https://www.manning.com/books/ruby-in-practice)**
>
> Like Ruby itself, Ruby in Practice will make you more productive. The book shows you practical techniques and strategies for small projects and large-scale environments. A cookbook-style reference, it gives you concrete examples of systems...

My free Ruby e-book

> **[Site not found · DreamHost](http://www.humblelittlerubybook.com/)**
>
> The owner of this domain has not yet uploaded their website.

My blogs:

> **[Site not found · DreamHost](http://www.mrneighborly.com/)**
>
> The owner of this domain has not yet uploaded their website.

[http://www.rubyinpractice.com/](http://www.rubyinpractice.com/)
