I''m working on a role based authentication scheme. It defines roles, which are assigned to users. The roles are action->controller pairs, and if a user has a role containing an action/controller, they my access that pair. Works great. However, the administration needs to auto-discover all possible action->controller pairs for the entire application. Now, I can get a list of all controllers, no problem. The problem is that the controller has no way to tell me what it''s possible actions are. I can get function lists, hidden actions, and all that, but no way of getting just plain old actions from a controller class or an instantiated controller. Any ideas? -- 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 rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk -~----------~----~----~----~------~----~------~--~---
Jason Roelofs
2006-Sep-28 15:11 UTC
Re: Getting a list of possible actions from a controller
As ''actions'' are simply the methods defined on the controller, this should work (though I can''t test it right now): ControllerClass.instance_methods - ActionController::Base.instance_methods Jason On 9/28/06, Mike <rails-mailing-list-ARtvInVfO7ksV2N9l4h3zg@public.gmane.org> wrote:> > > I''m working on a role based authentication scheme. > > It defines roles, which are assigned to users. > > The roles are action->controller pairs, and if a user has a role > containing an action/controller, they my access that pair. > > Works great. > > However, the administration needs to auto-discover all possible > action->controller pairs for the entire application. > > Now, I can get a list of all controllers, no problem. > > The problem is that the controller has no way to tell me what it''s > possible actions are. I can get function lists, hidden actions, and all > that, but no way of getting just plain old actions from a controller > class or an instantiated controller. > > Any ideas? > > -- > 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 rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk -~----------~----~----~----~------~----~------~--~---
Maxim Kulkin
2006-Sep-28 15:21 UTC
Re: Getting a list of possible actions from a controller
On 28 September 2006 19:11, Jason Roelofs wrote:> As ''actions'' are simply the methods defined on the controller, this should > work (though I can''t test it right now): > > ControllerClass.instance_methods - ActionController::Base.instance_methodsThis won''t work because not all instance methods are considered actions. Some methods are hidden (with hide_actions method). You''d better use class method ActionController::Base.action_methods or it''s instance method analogue. --~--~---------~--~----~------------~-------~--~----~ 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 rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk -~----------~----~----~----~------~----~------~--~---
Jason Roelofs
2006-Sep-28 15:49 UTC
Re: Getting a list of possible actions from a controller
Ah, so there is something like that. You''ll have to go diving around in ActionController itself to find such methods though, they aren''t on the documentation most of the time. Jason On 9/28/06, Maxim Kulkin <maxim.kulkin-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> > > On 28 September 2006 19:11, Jason Roelofs wrote: > > As ''actions'' are simply the methods defined on the controller, this > should > > work (though I can''t test it right now): > > > > ControllerClass.instance_methods - ActionController:: > Base.instance_methods > This won''t work because not all instance methods are considered actions. > Some > methods are hidden (with hide_actions method). > > You''d better use class method ActionController::Base.action_methods or > it''s > instance method analogue. > > > >--~--~---------~--~----~------------~-------~--~----~ 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 rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk -~----------~----~----~----~------~----~------~--~---
Cayce Balara
2006-Sep-28 17:22 UTC
Re: Getting a list of possible actions from a controller
The "user" engine does this in the Permission model (synchronize_with_controllers method). Take a look at that code for ideas. c. Mike wrote:> I''m working on a role based authentication scheme. > > It defines roles, which are assigned to users. > > The roles are action->controller pairs, and if a user has a role > containing an action/controller, they my access that pair. > > Works great. > > However, the administration needs to auto-discover all possible > action->controller pairs for the entire application. > > Now, I can get a list of all controllers, no problem. > > The problem is that the controller has no way to tell me what it''s > possible actions are. I can get function lists, hidden actions, and all > that, but no way of getting just plain old actions from a controller > class or an instantiated controller. > > Any ideas?-- 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 rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk -~----------~----~----~----~------~----~------~--~---