Marnen Laibow-Koser wrote:
> Colin Law wrote:
>> On 6 July 2010 21:38, Marnen Laibow-Koser <[email protected]> wrote:
>>> �end
>>> end
>>>
>>> then (unless I'm badly mistaken) you can get to the write_shakespeare
>>> method by (say) calling
>>>
>>> redirect_to :controller => 'plays', :action => 'write_shakespeare'
>>>
>>> regardless of what's in your routes file. �There may not be a direct URL
>>> to that action, but that doesn't prevent it from being an action.
>> 
>> In fact would it be true to say that no method of a controller is
>> inherently an action or not an action?  
> 
> No.  In  Rails, every public controller method is, by definition, an 
> action.  Period.  That's all.

OK, I now have to modify my answer.  With Ralph's latest question, I see 
what you're getting at.  So, here's the modified answer:

In Rails, every public controller method can, by definition, *behave as* 
an action -- that is, it can be called with suitable use of render 
:controller, :action.  It can also be called with a regular Ruby-style 
method call, in which case it does not behave as an action.

Whether a public controller method behaves as an action depends not on 
the method itself but on how it's called.

That said, if you have a controller method (such as Ralph's 
fetch_logged_user) that is not meant to be called as an action, it is an 
extremely good idea to make it non-public (that is, private or 
protected) so that it cannot be called as an action accidentally (or 
maliciously).

Best,
--
Marnen Laibow-Koser
http://www.marnen.org
[email protected]

-- 
Posted via http://www.ruby-forum.com/.

-- 
You received this message because you are subscribed to the Google Groups "Ruby 
on Rails: Talk" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to 
[email protected].
For more options, visit this group at 
http://groups.google.com/group/rubyonrails-talk?hl=en.

Reply via email to