I am calling a function I made in application_helper but when I try to call it it keeps saying method undefined. If I put the function in the controller it runs just fine. any ideas? --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
did you mean when you put it in your controller''s helper file, it works? make sure you are using your helpers in your views, and not in your controller. Chris Habgood wrote:> I am calling a function I made in application_helper but when I try to > call it it keeps saying method undefined. If I put the function in > the controller it runs just fine. any ideas?-- 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?hl=en -~----------~----~----~----~------~----~------~--~---
Should have used Hamburger Helper. I think application.rb doesn''t reload unless you restart the server. Maybe application_helper is the same way and it looks like this post agrees: http://www.ruby-forum.com/topic/155700 On Fri, Feb 6, 2009 at 11:30 PM, Eddie Son <rails-mailing-list-ARtvInVfO7ksV2N9l4h3zg@public.gmane.org> wrote:> > did you mean when you put it in your controller''s helper file, it works? > > make sure you are using your helpers in your views, and not in your > controller. > > > Chris Habgood wrote: > > I am calling a function I made in application_helper but when I try to > > call it it keeps saying method undefined. If I put the function in > > the controller it runs just fine. any ideas? > > -- > Posted via http://www.ruby-forum.com/. > > > >-- Available for Ruby on Rails development opportunities --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
Where are you trying to call it from? Helpers are for views Blog: http://random8.zenunit.com/ Learn rails: http://sensei.zenunit.com/ On 07/02/2009, at 6:30 PM, Eddie Son <rails-mailing-list@andreas- s.net> wrote:> > did you mean when you put it in your controller''s helper file, it > works? > > make sure you are using your helpers in your views, and not in your > controller. > > > Chris Habgood wrote: >> I am calling a function I made in application_helper but when I try >> to >> call it it keeps saying method undefined. If I put the function in >> the controller it runs just fine. any ideas? > > -- > 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?hl=en -~----------~----~----~----~------~----~------~--~---
That sounds strange. All controllers reload, therefore application controller does too, because it''s an abstract class. Blog: http://random8.zenunit.com/ Learn rails: http://sensei.zenunit.com/ On 07/02/2009, at 7:08 PM, Alan Brown <stretch-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> Should have used Hamburger Helper. > > I think application.rb doesn''t reload unless you restart the > server. Maybe application_helper is the same way > > and it looks like this post agrees: > > http://www.ruby-forum.com/topic/155700 > > On Fri, Feb 6, 2009 at 11:30 PM, Eddie Son <rails-mailing-list-ARtvInVfO7ksV2N9l4h3zg@public.gmane.org > > wrote: > > did you mean when you put it in your controller''s helper file, it > works? > > make sure you are using your helpers in your views, and not in your > controller. > > > Chris Habgood wrote: > > I am calling a function I made in application_helper but when I > try to > > call it it keeps saying method undefined. If I put the function in > > the controller it runs just fine. any ideas? > > -- > Posted via http://www.ruby-forum.com/. > > > > > > -- > Available for Ruby on Rails development opportunities > > >--~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
OK, so you can only call functions in a controller that are in a model? I have an app that does not have a model but I guess I can create one if need be. On Feb 7, 3:50 am, Julian Leviston <jul...-AfxEtdRqmE/tt0EhB6fy4g@public.gmane.org> wrote:> That sounds strange. All controllers reload, therefore application > controller does too, because it''s an abstract class. > > Blog:http://random8.zenunit.com/ > Learn rails:http://sensei.zenunit.com/ > > On 07/02/2009, at 7:08 PM, Alan Brown <stre...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote: > > > Should have used Hamburger Helper. > > > I think application.rb doesn''t reload unless you restart the > > server. Maybe application_helper is the same way > > > and it looks like this post agrees: > > > http://www.ruby-forum.com/topic/155700 > > > On Fri, Feb 6, 2009 at 11:30 PM, Eddie Son <rails-mailing-l...@andreas-s.net > > > wrote: > > > did you mean when you put it in your controller''s helper file, it > > works? > > > make sure you are using your helpers in your views, and not in your > > controller. > > > Chris Habgood wrote: > > > I am calling a function I made in application_helper but when I > > try to > > > call it it keeps saying method undefined. If I put the function in > > > the controller it runs just fine. any ideas? > > > -- > > Posted viahttp://www.ruby-forum.com/. > > > -- > > Available for Ruby on Rails development opportunities > >--~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
On Feb 7, 1:28 pm, Me <chabg...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> OK, so you can only call functions in a controller that are in a > model?You can call methods from pretty much anywhere, but that is not the point. In Rails, you want to follow their MVC pattern to get the most of the framework.You want to call methods within the scope of where you are at. The browser requests go from Dispatcher -> Controller -> View The purpose of the controller is to get the request, maybe validate the user, then instantiate an object that will be rendered in the view. That''s it. Any logic about the specifics of how to instantiate the object should be handled by the model classes. So in that part, you are correct when you say "only call functions in a controller that are in a model". You are making a call to instantiate an object that will be used in the view. The model classes usually have a database back end but it does not have to be. It is common to have model classes for specialized reports for example, that have aggregation methods, etc. So you should create a model class for what you are trying to do, to separate those methods in their own domain. Finally, the purpose of the Helper classes is to provide methods for the View. When you need to format something, etc. you put call methods in either the controller_helper class or the generic application helper class. Hope that helps. --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---