OnRails
2008-Jan-09 21:12 UTC
Can I call a function from app/controller/application.rb into app/models?
Can I call a function from app/controller/application.rb in app/ models? because when I run test units, I got "NoMethodError: undefined method `get_person'' for #<Class:0x6aec8f0>" but I define get_person into application.rb. and I know, when run rails, the first time load controller, then models, at last is view. So I think, I can call this method "get_person" from application.rb in models, but there is wrong. why? Thanks! --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
Jeremy Weiskotten
2008-Jan-09 21:15 UTC
Re: Can I call a function from app/controller/application.rb
OnRails wrote:> Can I call a function from app/controller/application.rb in app/ > models? > because when I run test units, I got "NoMethodError: undefined method > `get_person'' for #<Class:0x6aec8f0>" > but I define get_person into application.rb. and I know, when run > rails, the first time load controller, then models, at last is view. > So I think, I can call this method "get_person" from application.rb in > models, but there is wrong. why? > Thanks!You can''t call the method without being or having an instance of a controller that extends ApplicationController. I suggest learning more about object-oriented programming. -- 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 -~----------~----~----~----~------~----~------~--~---