Skip to content

Commit

Permalink
Merge pull request #223 from iNecas/fix-cache-generation
Browse files Browse the repository at this point in the history
Fix generating the cache in production environment
  • Loading branch information
iNecas committed Mar 13, 2014
2 parents 249d1ea + 5670663 commit 310a0c2
Showing 1 changed file with 15 additions and 5 deletions.
20 changes: 15 additions & 5 deletions lib/apipie/application.rb
Original file line number Diff line number Diff line change
Expand Up @@ -259,9 +259,13 @@ def api_controllers_paths
end

def reload_documentation
rails_mark_classes_for_reload
init_env
reload_examples
if rails_mark_classes_for_reload
# if we are not able to mark classes for reload, we
# can't reinit the env, as we would loose the data that were
# already loaded
init_env
reload_examples
end

api_controllers_paths.each do |f|
load_controller_from_file f
Expand Down Expand Up @@ -350,9 +354,15 @@ def ignored?(controller, method = nil)
# docs, therefore we just force to reload all the code. This
# happens only when reload_controllers is set to true and only
# when showing the documentation.
#
# If cache_classes is set to false, it does nothing,
# as this would break loading of the controllers.
def rails_mark_classes_for_reload
ActiveSupport::DescendantsTracker.clear
ActiveSupport::Dependencies.clear
unless Rails.application.config.cache_classes
ActiveSupport::DescendantsTracker.clear
ActiveSupport::Dependencies.clear
return true
end
end

end
Expand Down

0 comments on commit 310a0c2

Please sign in to comment.