I am not quite clear on the life cycle of instance variables in Ruby on Rails.
I have an instance variable
@work_days
(into which I fetch and load the list of all working days in a month. The month is selected by the user from adate_select
in the UI).Now I have a
Generate Report
button which generates an excel report by calling ashow
method in the controllerEvery time the user clicks the
Generate Report
button (andshow
method gets called), the value of@work_days
seems to benil
and I have to initialize it every time.
Is there a way to avoid this? Why does the value of instance variable become nil
every time the controller's method show
is called?