/
application.rb
43 lines (33 loc) · 1.08 KB
/
application.rb
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
# Filters added to this controller apply to all controllers in the application.
# Likewise, all the methods added will be available for all controllers.
class Application < ActionController::Base
include AuthenticatedSystem
protect_from_forgery
rescue_from ActiveRecord::RecordNotFound, :with => :not_found
helper :all # include all helpers, all the time
filter_parameter_logging :password, :password_confirmation
def current_post
@current_post ||= Post.find_by_permalink(params[:id], :include => :comments) || Post.find(params[:id])
end
protected
def post_repo
begin
@post_type = post_type.to_s.tableize
@post_type.classify.constantize
rescue => e
logger.info(e)
@post_type = :posts
retry
end
end
def not_found
cookies[:error] = "Sorry but that post could not be found."
redirect_to root_path and return
end
private
def expire_path(file)
file = File.join(Rails.root.to_str, 'public', file)
FileUtils.rm_rf(file) if File.exists?(file)
logger.info("Expired cache: #{file}")
end
end