class RtmlController < (defined? Rails) ? ApplicationController : ActionController::Base unless include?(Rtml::Controller::RenderHelpers) include Rtml::Controller::BeforeFilters include Rtml::Controller::RenderHelpers include Rtml::Controller::RtmlHelpers include Rtml::Controller::State include Rtml::Controller::CacheHelpers include Rtml::Controller::TemplateHelpers include Rtml::Controller::UrlHelpers extend Rtml::Controller::ClassMethods::RtmlActionHelpers end hide_action :rtml_document, :rtml_exception hide_action :screen_layout, :embedded_app helper_method :screen_layout, :embedded_app rescue_from Exception, :with => :rtml_exception # These are instance variables which will not be copied into RTML Actions or Widgets. class_inheritable_array :rtml_protected_instance_variables read_inheritable_attribute(:rtml_protected_instance_variables) || write_inheritable_attribute(:rtml_protected_instance_variables, %w( @during_finalization_blocks @terminal_state @rtml_helpers @exception @rtml_document @_request @render_proxy @real_format @update @template )) delegate :rtml_protected_instance_variables, :to => "self.class" def rtml_exception add_view_path(File.expand_path(File.join(Rtml.root, 'builtin/views'))) method = (ENV['RAILS_ENV'] == 'production') ? 'rescue_action_in_public' : 'rescue_action_locally' # to address the scenario "what if these methods were not defined due to a failing before_filter" rtml = false rtml = request.rtml? if request.respond_to?(:rtml?) rtml = response.rtml? if response.respond_to?(:rtml?) if (params[:error_mode] == 'rtml' || rtml) && rtml_helpers.respond_to?(method) @exception = $! Rails.logger.error $!.message Rails.logger.error $!.backtrace.join("\n ") rtml_document.reset! erase_results render :rtml => method else raise $! end end def embedded_app "emb://embedded.tml" end def screen_layout "rtml/#{state[:model]}" end def rtml_document @rtml_document ||= Rtml::Document.new(:name => "#{controller_name}/#{action_name}", :view_paths => view_paths, :controller => self) end protected def add_view_path(path) view_paths << path rtml_document.view_paths << path end end