I want to get the gender of a person from a helper method like so:
sportists_helper.rb
def sportists_gender
gender = self.gender
if gender == "1"
"Male"
elsif gender == "2"
"Female"
end
end
and then print it out in a view: <%= sportists_gender %>
, but this gives me undefined method 'gender'
error, why is that?
Assuming you have Person model. here is an example:
Helper:
Call From View.erb: