On Sat, Nov 19, 2005 at 05:35:36PM -0800, Dan B. wrote:
I noticed that instance variables in a controller
are automatically available to corresponding templates in the view.
Can any of you explain how this magic is implemented?
It’s in actionpack/lib/action_controller/base.rb
And then in actionpack/lib/action_view/base.rb
What I’d like to do is work some more of this magic so I can access
the instance variables from within functional tests.
In functional tests you can use the assigns method that is documented
In your controller:
class FooController < ApplicationController
@baz = ‘…’
In your functional test:
assert_equal ‘…’, assigns(:baz)
Marcel Molina Jr. firstname.lastname@example.org