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
|
# File 'lib/taggable/site_controller.rb', line 4
def self.included(base)
base.class_eval {
def find_page_with_tags(path)
path = clean_path(path)
page = find_page_without_tags(path)
if page.respond_to?(:requested_tags)
page.add_request_tags(Tag.in_this_list(params[:tag])) if params[:tag]
raise Taggable::RedirectRequired, page.path unless page.path == path
end
page
end
alias_method_chain :find_page, :tags
def show_page_with_tags
show_page_without_tags
rescue Taggable::RedirectRequired => e
redirect_to e.message
end
alias_method_chain :show_page, :tags
protected
def clean_path(path)
"/#{ path.strip }/".gsub(%r{//+}, '/')
end
}
end
|