I have a route in my routes.rb file:
map.connect 'login', :controller => 'users', :action => 'login'
and I have a partial being rendered in a view as:
login_path
This view gets called in the functional test of the controller.
However, in the functional test I get the error:
ActionView::TemplateError: undefined local variable or method `login_path' for #<ActionView::Base:0x4762c90>
1) What's the best way of mocking it for the test?
2) Does this indicate a design flaw?
map.connect
will add an unnamed route. What you probably want in your routes.rb
is:
map.login 'login', :controller => 'users', :action => 'login'
That will create the named routes login_path
and login_url
for you.