I am trying to access an instance variable from a js.erb file.
#controller
def get_person
@person = Person.find(1)
respond_to do |format|
format.js{}
end
end
#get_person.js.erb
alert('<%= @person.last_name %>')
When I browse to [controller_name_here]/get_person.js ... I get a nil object error on @person. (I know Person.find(1) returns an object)
Note: I am actually having trouble rendering a partial in my js.erb file and am trying to identify the cause.