Given the following helper:
def hide_contact_details!
@hide_contact_details = true
end
def show_contact_details?
@!hide_contact_details
end
I want to call hide_contact_details!
from a select few controllers and use show_contact_details?
around my templates.
However, when I use the view_context
object from a controller in Rails 3, it seems to point to a different object than my view.
@hide_contact_details
is nil, unless I call hide_contact_details! from within the view, rather than through view_context.hide_contact_details!
in the view.
How can I call a (helper)method in the controller, that sets a boolean which is accessible to the helper in the view?