def self.all_holidays_in(y) #
from = Date.civil(y,1,1) #
to = Date.civil(y,12,31) #
return Holidays.between(from, to, self.countrycode)
end
You need to make it a class method by doing self.method_name
In fact that won't work, hadn't noticed the country code. Leave the method as it is but you need an instance of the country to call it.
So if in you controller you have
@country = Country.first
You can then do
@country.all_holidays_in(2014)
With your current method.