forked from fatfreecrm/fat_free_crm
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Added PrependEngineViews library module to let Fat Free CRM plugins o…
…verride default views
- Loading branch information
Mike Dvorkin
committed
Aug 18, 2010
1 parent
5ea3724
commit 07c2ba8
Showing
2 changed files
with
43 additions
and
0 deletions.
There are no files selected for viewing
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
# Fat Free CRM | ||
# Copyright (C) 2008-2010 by Michael Dvorkin | ||
# | ||
# This program is free software: you can redistribute it and/or modify | ||
# it under the terms of the GNU Affero General Public License as published by | ||
# the Free Software Foundation, either version 3 of the License, or | ||
# (at your option) any later version. | ||
# | ||
# This program is distributed in the hope that it will be useful, | ||
# but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
# GNU Affero General Public License for more details. | ||
# | ||
# You should have received a copy of the GNU Affero General Public License | ||
# along with this program. If not, see <http:#www.gnu.org/licenses/>. | ||
#------------------------------------------------------------------------------ | ||
|
||
module FatFreeCRM | ||
# The following is taken from PrependEngineViews plugin for Redmine | ||
# (see http://github.com/edavis10/prepend_engine_views/blob/master/init.rb) | ||
# It basically lets any Fat Free CRM plugin override default views. | ||
module PrependEngineViews | ||
def self.included(base) | ||
base.send(:include, InstanceMethods) | ||
base.class_eval do | ||
alias_method_chain :add_engine_view_paths, :prepend | ||
end | ||
end | ||
|
||
module InstanceMethods | ||
# Patch Rails so engine's views are prepended to the view_path, | ||
# thereby letting plugins override application views | ||
def add_engine_view_paths_with_prepend | ||
paths = ActionView::PathSet.new(engines.collect(&:view_path)) | ||
ActionController::Base.view_paths.unshift(*paths) | ||
ActionMailer::Base.view_paths.unshift(*paths) if configuration.frameworks.include?(:action_mailer) | ||
end | ||
end | ||
end | ||
end |