I have a policy class and in that class I have 2 methods which determin whether or not a customer can renew their policy.
They look like this: (in the policy.rb model)
def is_renewable?
if has_not_been_renewed?
self.ends_on >= Date.today && self.ends_on <= Date.today + 60.days
end
end
def has_not_been_renewed?
been_renewed = self.renewed_policy.nil? || !self.renewed_policy.active? || !self.active?
end
So for some reason this is working on my local machine but not in our staging enviroment. (I know right, the bane of every programmer "But it works on my machine!").
The logic seems simple: first check to make sure it hasn't been renewed already or that they have a different active policy. Then check to make sure it hasn't already expired and that it will expire sometime in the next 60 days.
This is called from this line in the view:
<%= link_to('Renew', {:action => 'renew', :id => policy.id}, {:class => 'btn btn-success'}) if policy.is_renewable? %>
I am really failing to see why this wouldn't work anywhere. I wouldn't ask but I have been looking at this stupid problem all day and need a new set of eyes to look it over. Thanks
Incase this helps, the format for both database's (local and staging) is in the form:
yyyy-mm-dd
so today's date would be 2012-09-06
.