lib/cachai.rb in cachai-0.1.0 vs lib/cachai.rb in cachai-0.1.1
- old
+ new
@@ -1,7 +1,6 @@
require 'sinatra/base'
-require 'sendgrid-ruby'
require 'redis'
require 'json'
require_relative 'models'
require_relative 'akismet'
@@ -34,10 +33,11 @@
else
puts "No Akismet key found! Will not check comments for spam."
end
if sendgrid_opts = opts.delete(:sendgrid)
+ require 'sendgrid-ruby'
@sendgrid = SendGrid::Client.new(sendgrid_opts)
@recipient = opts.delete(:recipient) or raise "No recipient set!"
end
super(app)
@@ -246,10 +246,16 @@
deliver @comment, :comment
end
put '/comments/:id' do
@comment = Cachai::Response.find(params[:id])
- @comment.update_attributes(params[:comment])
+ if @comment.update_attributes(params[:comment])
+ begin
+ @comment.post.clear_cache
+ rescue => e
+ puts e.message
+ end
+ end
redirect back
end
def deliver(obj, view)
if request.xhr?