Forum: Ruby on Rails NoMethodError trying to get ApplicationHelper method from a

Announcement (2017-05-07): www.ruby-forum.com is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see rubyonrails.org/community and ruby-lang.org/en/community for other Rails- und Ruby-related community platforms.
F0d09ef2a279cae4ac312164aa1af6d3?d=identicon&s=25 Ian Connor (Guest)
on 2006-05-07 09:32
(Received via mailing list)
I am a little confused by the includes I suspect. In the book, it states
that runtime environment will load the directories app, app/models,
app/controllers, app/helpers, app/apis, components, config, lib, vendor
and
vendor/rails/*.

However, when I try to access my "current_project" public method, it
fails
with a NoMethodError.

What is even stranger is that I can use reflection to find that the
method
is indeed there. For instance, this code:

 def test_should_login_and_redirect
     ApplicationHelper.public_instance_methods.each do |method|
      if method == "current_project"
        puts "calling " + method
        puts ApplicationHelper.send(method)
      end
    end
...

Will find the method but then when it is called, it will still complain
yeilding:

Loaded suite test/functional/account_controller_test
Started
..calling current_project
E
Finished in 0.172 seconds.

  1) Error:
test_should_login_and_redirect(AccountControllerTest):
NoMethodError: undefined method `current_project' for
ApplicationHelper:Module
    test/functional/account_controller_test.rb:31:in `send'
    test/functional/account_controller_test.rb:31:in
`test_should_login_and_redirect'
    test/functional/account_controller_test.rb:28:in `each'
    test/functional/account_controller_test.rb:28:in
`test_should_login_and_redirect'

3 tests, 4 assertions, 0 failures, 1 errors

So I am really confused how it can know the module is there, be able to
find
the method in question and then claim to not know the method at all. If
anyone knows the trick to getting the helpers to be called from the
tests,
that would be really appreciated.

--
Regards,
Ian Connor
This topic is locked and can not be replied to.