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
44
|
# File 'app/controllers/pages_controller.rb', line 18
def show
@sidebar = true
if params[:id]
@sitemap ||= resource.sitemaps.sort{|t,u| t.url.size <=> u.url.size}[0]
@page = resource
else
@sitemap = Sitemap.from_request_params(params)
@page = @sitemap.try(:resource)
end
if @page
@child_pages = Sitemap.accessible_by(current_ability).where(:parent_id=>@sitemap.id)
if can_access_resources?
respond_with @page, @sitemap, @child_pages, @attachments
else
if user_signed_in?
flash[:notice] = "How did you find that page? Please contact your administrator if you believe you should have access to that resource."
redirect_to root_url
else
authenticate_user!
end
end
else
flash[:notice] = "Sorry, we couldn't find the resource you were looking for!"
redirect_to root_url
end
end
|