Hi all I''m having an authorization method that looks like the following: def user_requests_authorization_to(right_name) ... end I find it boring to always use user_requests_authorization_to(''EDIT'') user_requests_authorization_to(''CREATE'') etc., so I thought I could implement my own dynamic method, like the dynamic finders! Instead of the calls above I''d like to call user_requests_authorization_to_edit user_requests_authorization_to_create How can I achieve that? :-) Thanks a lot, Josh -- 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?hl=en -~----------~----~----~----~------~----~------~--~---
On 23 Nov 2007, at 13:31, Joshua Muheim wrote:> > etc., so I thought I could implement my own dynamic method, like the > dynamic finders! Instead of the calls above I''d like to call > > user_requests_authorization_to_edit > user_requests_authorization_to_create >You need to override method_missing, ie def method_missing(method_id, *arguments) if method_id looks like user_requests_authorization_to_something user_requests_authorization_to(something) else super end end Fred> How can I achieve that? :-) Thanks a lot, Josh > -- > 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?hl=en -~----------~----~----~----~------~----~------~--~---
Thank you :-) -- 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?hl=en -~----------~----~----~----~------~----~------~--~---
Reasonably Related Threads
- Questions on Active Record SQL type Finders & Dynamic Finder
- ActiveRecord 'find_or_initialize_by' dynamic finder bug? Ignoring conditions.
- habtm on an array (or object.habtm.habtm)
- Easy way to handle form input without a model class?
- [LLVMdev] Hash Table Virtual Calls with Conflict Resolution Stubs