Pastie now auto-senses if line-wrap is a bad or good idea. Feedback?
## mark a section (Learn more)
## config/environment.rb [in initializer loop] if Rails.env.production? config.after_initialize do port = RAILS_ENV == "production" ? 11300 : 11310 AsyncObserver::Queue.queue = Beanstalk::Pool.new(["localhost:#{port}"]) # This value should change every time you make a release of your app. AsyncObserver::Queue.app_version = 1.0 end end ## app/models/product.rb def check_image_url unless image_url.blank? if image_url_checked_at.nil? || (image_url_good? && image_url_checked_at < 2.weeks.ago) begin async_send :ensure_image_url rescue Beanstalk::NotConnected Norman.deliver_shout "Beanstalkd server did not connect in #{RAILS_ENV} mode at #{Time.now}", "Product image checking will not be available until this is rectified" end end end end def ensure_image_url return unless Rails.env.production? begin response = SimpleHttp.head(image_url) content_type = response["content-type"] if content_type =~ /^image/ self.image_url_good = true else self.image_url_good = false end rescue Errno::ETIMEDOUT return rescue RuntimeError, SocketError => err self.image_url_good = false end self.image_url_checked_at = Time.now ThinkingSphinx.deltas_enabled = false save false # Don't validate, just save! ThinkingSphinx.deltas_enabled = true end
This paste will be private.
From the Design Piracy series on my blog: