is there any way to persist (preserve) parameters in Rails controller? It should be passed to every action, then to every view and every link.
Example situation:
I have entity A with its controller. Besides, I have another entity B which is dependent on A. I need to access the “parent” A entity very often, so I’d like to have it still as
http://some_url/b_controller/b_action?a_entity=xyz
You should be able to do everything from your controller, using a combination of
before_filteranddefault_url_options:This doesn’t solve the problem of setting the initial value of
@a_entity, but this can be done from anywhere (view, controller, etc).If you want this parameter passed around in multiple controllers, you can replace
MyController < ApplicationControllerwithApplicationController < ActionController::Baseand it should work as well.Hope this helps.