I have an assignment with many assessments and am using fields_for to traverse the nested assessment information.
On the assessment I have an ID value that I want to translate to its name. I want to pass that ID to a helper and return back the string name but I can't seem to get to the ID value?
My code is
<%= form_for assignment do |f| %>
<%= f.fields_for :assignmentassessments do |ff| %>
<div class="row">
<div class="col-4">
<% strength_name(:strength_id) %>
</div>
And the helper is
module AssignmentsHelper
def strength_name(id)
if id != nil
@strength = Strength.find_by(id: id)
@strength.name
end
end
end
I am getting undefined method name for nil:NilClass
because when I pass :strength_id
it is coming through as nil