In the scenario where I have a View called home.html.erb
and the corresponding controller shown below:
class StaticController < ApplicationController
def home
@people = Person.all
end
def filter
@people = ....
end
def contact
end
end
Upon initial page load, I am able to access the people using @people
. However, an issue arises when I attempt to apply filters. To do so, I trigger an AJAX action from my home view
, which in turn calls the filter
action to update the @people
variable.
The problem arises as even after updating the variable value to @people2
:
def filter
@people2 = ....
end
An error is thrown when trying to iterate through @people2
within the View, indicating that @people2
is null. This raises the question of how to correctly access this variable from the View.
Any insights on this would be greatly appreciated. Thank you.