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!
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.