On Jan 22, 2010, at 1:02 PM, John Merlino wrote:

I'm looking at code in a project. I have no clue what is being passed
into the resource parameter:

   def read_authorized?(resource)
     if resource.respond_to? :user_read_authorized?
       resource.user_read_authorized? current_user
     else
       true
     end
   end

Is there any kind of debugging feature I can run to see what gets passed
into resource in this specific instance.

Also, user_read_authorized? is not defined anywhere else in application.
Is that legal in rails? Can someone just define :user_read_authorized?
and it mean something?

Thanks for any suggestions

As to the second part of your question, it is perfectly "legal" to define your own method names and the behavior that you expect. In this case, it seems like a resource (probably a model) is presumed to be readable (true) unless the resource has defined its own :user_read_authorized? method that takes a user and supplies a particular answer (and if a login has not been required, current_user might be false).

Shame on you if your method names don't make sense, of course. ;-)

-Rob

Rob Biedenharn          http://agileconsultingllc.com
[email protected]



--
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