railstutorial.org has a suggestion which strikes me as a little odd. Here: http://ruby.railstutorial.org/chapters/sign-in-sign-out#code:sessions_helper_include ... it suggests this code: class ApplicationController < ActionController::Base protect_from_forgery include SessionsHelper end ...making SessionsHelper available essentially everywhere. I understand that authentication/authorization is cross-cutting, but is this really the best place? Would functionality not strictly needed in views be better placed in ApplicationController or elsewhere? Thoughts? Thanks, -Craig -- 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-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
On 30 March 2011 03:36, Craig Stuntz <craigstuntz-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> railstutorial.org has a suggestion which strikes me as a little odd. > Here: > > http://ruby.railstutorial.org/chapters/sign-in-sign-out#code:sessions_helper_include > > ... it suggests this code: > > class ApplicationController < ActionController::Base > protect_from_forgery > include SessionsHelper > end > > ...making SessionsHelper available essentially everywhere. I > understand that authentication/authorization is cross-cutting, but is > this really the best place? Would functionality not strictly needed in > views be better placed in ApplicationController or elsewhere?The above code *does* put it in ApplicationController. Perhaps I misunderstand your question. Colin -- 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-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe@googlegroups.com. For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
Craig Stuntz
2011-Mar-30 10:56 UTC
Re: SessionsHelper in railstutorial.org: A good design?
The SessionsHelper option makes the methods available from ApplicationController, yes, but it makes them available in any view, as well. That seems to me to be potentially too broad of a scope. Also, putting code which implements, say, a before_filter which conditionally redirects (as the railstutorial.org example does) in a module which more commonly contains view helpers seems surprising. I''m not sure if my concerns are well-founded or if I''m "thinking too much" about this. -Craig -- 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-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe@googlegroups.com. For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.