I have a set of functions that access some app-specific session variables used for ACL and other sundry items. The dilema is that I need to access these functions from both controller code and viewer code. Is there a single place I can put these functions where they will be accesible to both? Making them application helpers gets scope to the views but not to the controllers. At the moment I have them cloned so I can access them in both places. What seems crazy is if I just inline the code that accesses the session variables it works from controllers and views, but I''d rather put the code in one spot callable by both so I have gotten away from inlining. I have also tried putting them in a module (/public/lib) but in a module they seem to only be accesible to controller and/or model code. -- 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 -~----------~----~----~----~------~----~------~--~---
Mike Kogan wrote:> I have a set of functions that access some app-specific session > variables used for ACL and other sundry items. The dilema is that I need > to access these functions from both controller code and viewer code. Is > there a single place I can put these functions where they will be > accesible to both?You can put these methods in your application controller, and then specify they are also helper methods: class ApplicationController < ActionController::Base helper_method :logged_in? def logged_in? session[:user_id].nil? ? false : true end end -- 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 -~----------~----~----~----~------~----~------~--~---
Very handy and cool. Thanks! -- 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 -~----------~----~----~----~------~----~------~--~---