def has_pressure_sensor
y_n = ‘n’
self.sites.each do |site|
if site.option = ‘pressure’
y_n = ‘y’
end
end
end
Hrm… I don’t know the rest of your models, but guessing I think your
method should look more like this if only because your calling
‘self.sites’ which according to your model above a site doesn’t have
sites…
def has_pressure_sensor?
self.site_options.each do |option|
return true if option == ‘pressure’
end
false
end
That will return true if one of the site_options for that site equals
‘pressure’ otherwise false. The ‘?’ in the name is a ruby convetion
when
you’re querying truth/false-ness.
Then in your view you could do:
<%= site.has_pressure_sensor? ? ‘yes’ : ‘no’ %>
As for why it’s not being seen, perhaps you are running in production
mode? Or for some other reason need to restart your rails app.