Hi All! This is not a problem in general but i''ve just missed the point. If my application has a global state, which i have to use both throughout ActionController and ActiveView, then, where to place that state? E.g. if I do this: class ApplicationController < ActionController::Base protected def authenticated? !user.nil? end end then I can''t use that from any View. And, on the other hand, if I do write that as a public method - it acts as an action... So, where to place such "global" properties? Thanx a lot! --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
Anyone? On Mar 14, 11:27 pm, sinm <sinm.s...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> Hi All! > This is not a problem in general but i''ve just missed the point. > If my application has a global state, which i have to use both > throughout ActionController and ActiveView, then, where to place that > state? > E.g. if I do this: > > class ApplicationController < ActionController::Base > protected > def authenticated? > !user.nil? > end > end > > then I can''t use that from any View. And, on the other hand, if I do > write that as a public method - it acts as an action... > > So, where to place such "global" properties? > > Thanx a lot!--~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
Rick Olson
2008-Mar-14 22:12 UTC
Re: ActionController <-> ActiveView code access ambiguity
On Fri, Mar 14, 2008 at 1:27 PM, sinm <sinm.sinm-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> > Hi All! > This is not a problem in general but i''ve just missed the point. > If my application has a global state, which i have to use both > throughout ActionController and ActiveView, then, where to place that > state? > E.g. if I do this: > > class ApplicationController < ActionController::Base > protected > def authenticated? > !user.nil? > end > end > > then I can''t use that from any View. And, on the other hand, if I do > write that as a public method - it acts as an action... > > So, where to place such "global" properties? > > Thanx a lot!http://rails.rubyonrails.org/classes/ActionController/Helpers/ClassMethods.html#M000284 class FooController helper_method :authenticated? end -- Rick Olson http://lighthouseapp.com http://weblog.techno-weenie.net http://mephistoblog.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 -~----------~----~----~----~------~----~------~--~---
Oh. Thanks. I''ll give it a try. On Mar 15, 1:12 am, "Rick Olson" <technowee...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> On Fri, Mar 14, 2008 at 1:27 PM, sinm <sinm.s...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote: > > > Hi All! > > This is not a problem in general but i''ve just missed the point. > > If my application has a global state, which i have to use both > > throughout ActionController and ActiveView, then, where to place that > > state? > > E.g. if I do this: > > > class ApplicationController < ActionController::Base > > protected > > def authenticated? > > !user.nil? > > end > > end > > > then I can''t use that from any View. And, on the other hand, if I do > > write that as a public method - it acts as an action... > > > So, where to place such "global" properties? > > > Thanx a lot! > > http://rails.rubyonrails.org/classes/ActionController/Helpers/ClassMe... > > class FooController > helper_method :authenticated? > end > > -- > Rick Olsonhttp://lighthouseapp.comhttp://weblog.techno-weenie.nethttp://mephistoblog.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 -~----------~----~----~----~------~----~------~--~---
Maybe Matching Threads
- Stop users accessing methods.
- (BUG in svn/trunk?) - superclass mismatch for any subclass of ApplicationController
- Can''t call public application.rb method from ERb template
- Set instance variable for all actions in the Controller
- Setting a global before_filter action in application.rb