Created
February 9, 2009 16:08
-
-
Save bastos/60845 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
... | |
before_filter :set_views_paths_for_layout | |
# Add new paths to templates paths. | |
def set_views_paths_for_layout | |
paths = [] | |
... | |
paths << create_a_new_path("#{RAILS_ROOT}/app/views/shared") | |
... | |
paths.each do |_path| | |
prepend_view_path _path if not view_paths.include?(_path) | |
end | |
end | |
# This method returns a ActionView::PathSet::Path object. | |
# Use-it instead of create a new instance every request couse if you do, will couse | |
# a lot of use of your File System (stat, stat64). Issue fount using Dtrace tool: dtruss. | |
# The SOLUTION is memoize this method and store all the results. | |
# | |
# ====References: | |
# http://apidock.com/rails/ActionView/Base/process_view_paths/class | |
# http://apidock.com/rails/ActionView/Base/new/class | |
# http://apidock.com/rails/ActionView/PathSet/type_cast/class | |
# | |
# ====Example: | |
# create_a_new_path("#{RAILS_ROOT}/app/views/otherpath") | |
def create_a_new_path(path) | |
@@paths_already_set ||= {} | |
return @@paths_already_set[path] if @@paths_already_set.has_key?(path) | |
@@paths_already_set[path] = ActionView::PathSet::Path.new(path) | |
return @@paths_already_set[path] | |
end | |
... |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment