Hi,

I have a model that calls the following method during validation:

validate :is_reachable

def is_reachable
    ping(false)
errors.add(:url, "page is not reachable") unless self.status == Page::Status::UP
end

def ping(notify_user = true)
    begin
         self.ping_at = Time.now + PING_INTERVAIL
      response = Net::HTTP.get_response(URI.parse(self.url))
      response.value()
      self.status = Page::Status::UP
    rescue Exception => e
      unless self.status == Page::Status::DOWN
        UserMailer.deliver_page_down(self, self.user) if notify_user
        self.status = Page::Status::DOWN
      end
    end
end

When the model is valid (i.e. exception is not raised and page is reachable, hobo renders user.page.show - correct.

When the model is invalid (i.e. exception is raised, catched and errors.add executes), hobo renders the user.pages.index -wrong.

Because the model is invalid, it doesn't get saved. Hobo should be serving user.pages.new again with the errors, but the rescue exception is affecting something.

I'm not doing any overrides on the Pages controller. I have auto_actions_for :user, [ :index, :new, :create].

Any clues? This is hobo 3 edge.

Thanks,
  TF

--
You received this message because you are subscribed to the Google Groups "Hobo 
Users" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to 
[email protected].
For more options, visit this group at 
http://groups.google.com/group/hobousers?hl=en.

Reply via email to