jackdan
2006-Aug-28 21:09 UTC
How to make code accessible in controller, view and possibly model
I am currently trying to implement the access control part of my project ( a bugzilla type project). My problem is the following. I have a set of basic functions to determine if a user has access to a bug (and what type of access). I would like these functions to be available all through my application (controller, views and hopefully model) but I can''t seem to find how. For the time being I duplicate the code in ApplicationController and ApplicationHelper to have the functions available in controllers and views, but this solution is obviously horrible. And it doesn''t even allow me to access the functions in the model. Any help would be appreciated, Jd --~--~---------~--~----~------------~-------~--~----~ 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-Aug-28 21:23 UTC
Re: How to make code accessible in controller, view and possibly model
Throughout the application, put them in a seperate class and put that class in RAILS_ROOT/lib. Rails reloads everything in lib/ on server restart, and you''ll have access to that class everywhere in your app. Jason On 8/28/06, jackdan <jd-FTd3qWkk0KTR7s880joybQ@public.gmane.org> wrote:> > > I am currently trying to implement the access control part of my > project ( a bugzilla type project). > > My problem is the following. I have a set of basic functions to > determine if a user has access to a bug (and what type of access). I > would like these functions to be available all through my application > (controller, views and hopefully model) but I can''t seem to find how. > > For the time being I duplicate the code in ApplicationController and > ApplicationHelper to have the functions available in controllers and > views, but this solution is obviously horrible. And it doesn''t even > allow me to access the functions in the model. > > Any help would be appreciated, > > Jd > > > > >--~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
jackdan
2006-Aug-28 21:57 UTC
Re: How to make code accessible in controller, view and possibly model
Thank you very much. It worked like a charm. --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---