Mr. Bless
2008-Nov-29 11:39 UTC
writing a method that is accessible from any views as well as any controller
HI guys where should i have to write the method that it is accessibible from any controller and any views. When i write the method in application controller then it is accessible in controller only and when i write it on application helper it is accessible on views only. I even tried to write it as module in the lib and included in the application controller, in that case it becomes inaccessible in views. --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
Mr. Bless
2008-Nov-29 11:40 UTC
writing a method that is accessible from any views as well as any controller
HI guys where should i have to write the method that it is accessible from any controller and any views. When i write the method in application controller then it is accessible in controller only and when i write it on application helper it is accessible on views only. I even tried to write it as module in the lib and included in the application controller, in that case it becomes inaccessible in views. --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
Fernando Perez
2008-Nov-29 14:45 UTC
Re: writing a method that is accessible from any views as we
Mr. Bless wrote:> HI guys where should i have to write the method that it is accessible > from any controller and any views. When i write the method in > application controller then it is accessible in controller only and > when i write it on application helper it is accessible on views only. > I even tried to write it as module in the lib and included in the > application controller, in that case it becomes inaccessible in views.Write the code in ApplicationController, declare it as protected. Then to make it accessible to views, still in application.rb, use the method: helper_method(your_method_name), and voilà. -- 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@googlegroups.com For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
Mr. Bless
2008-Dec-01 06:15 UTC
Re: writing a method that is accessible from any views as we
Thanks Perez. What i do now is that i write it in application helper and include it in application controller. On Nov 29, 9:45 am, Fernando Perez <rails-mailing-l...-ARtvInVfO7ksV2N9l4h3zg@public.gmane.org> wrote:> Mr. Bless wrote: > > HI guys where should i have to write the method that it is accessible > > from any controller and any views. When i write the method in > > application controller then it is accessible in controller only and > > when i write it on application helper it is accessible on views only. > > I even tried to write it as module in the lib and included in the > > application controller, in that case it becomes inaccessible in views. > > Write the code in ApplicationController, declare it as protected. Then > to make it accessible to views, still in application.rb, use the method: > helper_method(your_method_name), and voilà. > -- > Posted viahttp://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@googlegroups.com For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---