From bc9082a858670207e8e0506c8aa4a084653e5403 Mon Sep 17 00:00:00 2001 From: chris Date: Tue, 30 Oct 2012 17:10:59 +0800 Subject: [PATCH] Fix bug: Fix the bug due to not finding the ModuleApp --- app/controllers/orbit_backend_controller.rb | 12 +++++------- app/models/module_app.rb | 2 +- app/views/layouts/_side_bar_content.html.erb | 8 ++++---- 3 files changed, 10 insertions(+), 12 deletions(-) diff --git a/app/controllers/orbit_backend_controller.rb b/app/controllers/orbit_backend_controller.rb index 0ac853ed..8f78ea62 100644 --- a/app/controllers/orbit_backend_controller.rb +++ b/app/controllers/orbit_backend_controller.rb @@ -1,4 +1,4 @@ -class OrbitBackendController< ApplicationController +class OrbitBackendController < ApplicationController #before_filter :setup_vars #before_filter :set_current_user @@ -11,17 +11,15 @@ class OrbitBackendController< ApplicationController layout 'new_admin' def setup_vars - @app_title = request.fullpath.split('/')[2] - @app_title = request.fullpath.split('/')[1] if(@app_title == "back_end") - @app_title.gsub!(/[?].*/,'') - @module_app = ModuleApp.first(conditions: {:key => @app_title} ) + @app_title = controller_path.split('/')[1].singularize + @module_app ||= ModuleApp.first(conditions: {:key => @app_title} ) end private def force_order_for_visitor - setup_vars - set_current_user + setup_vars + set_current_user end diff --git a/app/models/module_app.rb b/app/models/module_app.rb index 8441e4fe..669d82aa 100644 --- a/app/models/module_app.rb +++ b/app/models/module_app.rb @@ -82,7 +82,7 @@ class ModuleApp protected def set_key - self.key = self.title.underscore if self.title + self.key = self.title.underscore.singularize if self.title end diff --git a/app/views/layouts/_side_bar_content.html.erb b/app/views/layouts/_side_bar_content.html.erb index 94c0b104..61888acc 100644 --- a/app/views/layouts/_side_bar_content.html.erb +++ b/app/views/layouts/_side_bar_content.html.erb @@ -14,7 +14,7 @@ <%= content_tag :li, link_to((t('announcement.categories') + content_tag(:i, nil, :class => 'icon-chevron-right')).html_safe, panel_announcement_back_end_bulletin_categorys_path), :class =>( active_for_action('bulletin_categorys', 'index') || active_for_ob_auths_object("BulletinCategory") )if (is_manager? rescue nil) %> <%= content_tag :li, link_to((t('announcement.tags') + content_tag(:i, nil, :class => 'icon-chevron-right')).html_safe, panel_announcement_back_end_tags_path), :class => active_for_action('/panel/announcement/back_end/tags', 'index')if (is_manager? rescue nil) %> <%= content_tag :li, link_to((t('announcement.bulletin.approval_setting') + content_tag(:i, nil, :class => 'icon-chevron-right')).html_safe, panel_announcement_back_end_approval_setting_path), :class => active_for_action('approvals', 'setting') if (is_manager? rescue nil) %> - <%= content_tag :li, link_to((t('admin.module.authorization') + content_tag(:i, nil, :class => 'icon-chevron-right')).html_safe,admin_module_app_manager_auth_proc_path(ModuleApp.first(conditions: {title: "Announcement"}))), :class => active_for_app_auth('Announcement') if (is_admin? rescue nil) %> + <%= content_tag :li, link_to((t('admin.module.authorization') + content_tag(:i, nil, :class => 'icon-chevron-right')).html_safe,admin_module_app_manager_auth_proc_path(ModuleApp.first(conditions: {key: "announcement"}))), :class => active_for_app_auth('Announcement') if (is_admin? rescue nil) %> <% end -%> @@ -46,14 +46,14 @@ <% end -%> -<%= content_tag :li, :class => active_for_controllers('ad_banners', 'ad_images') ||active_for_ob_auths_object("AdBanner") ||active_for_app_auth('ad_banners') do -%> +<%= content_tag :li, :class => active_for_controllers('ad_banners', 'ad_images') ||active_for_ob_auths_object("AdBanner") ||active_for_app_auth('ad_banner') do -%> <%= link_to content_tag(:i, nil, :class => 'icons-link') + content_tag(:span, t('admin.ad_banner')), admin_ad_banners_path %> <%= content_tag :ul, :class => ("nav nav-list " + visible_for_controllers('ad_banners', 'ad_images') ) do -%> <%#= content_tag :li, link_to(t('admin.ad.all_banners'), admin_ad_banners_path), :class => active_for_action('ad_banners', 'index') %> <%#= content_tag :li, link_to(t('admin.ad.new_banner'), new_admin_ad_banner_path), :class => active_for_action('ad_banners', 'new') %> <%#= content_tag :li, link_to(t('admin.ad.new_image'), new_ad_image_admin_ad_banners_path), :class => active_for_action('ad_images', 'new') %> - <%= content_tag :li, link_to((t('admin.module.authorization') + content_tag(:i, nil, :class => 'icon-chevron-right')).html_safe,admin_module_app_manager_auth_proc_path(ModuleApp.first(conditions: {key: "ad_banners"}))), :class => active_for_app_auth('ad_banners') if (is_admin? rescue nil) %> + <%= content_tag :li, link_to((t('admin.module.authorization') + content_tag(:i, nil, :class => 'icon-chevron-right')).html_safe,admin_module_app_manager_auth_proc_path(ModuleApp.first(conditions: {key: "ad_banner"}))), :class => active_for_app_auth('ad_banners') if (is_admin? rescue nil) %> <% end -%> <% end %> @@ -65,7 +65,7 @@ <%= content_tag :li, link_to((t('announcement.add_new') + content_tag(:i, nil, :class => 'icon-chevron-right')).html_safe, new_panel_web_resource_back_end_web_link_path), :class => active_for_action('web_links', 'new') if (is_manager? rescue nil)%> <%= content_tag :li, link_to((t('announcement.categories') + content_tag(:i, nil, :class => 'icon-chevron-right')).html_safe, panel_web_resource_back_end_web_link_categorys_path), :class => (active_for_action('web_link_categorys', 'index') || active_for_ob_auths_object("WebLinkCategory")) if (is_manager? rescue nil)%> <%= content_tag :li, link_to((t('announcement.tags') + content_tag(:i, nil, :class => 'icon-chevron-right')).html_safe, panel_web_resource_back_end_tags_path), :class => active_for_action('/panel/web_resource/back_end/tags', 'index') if (is_manager? rescue nil)%> - <%= content_tag :li, link_to((t('admin.module.authorization') + content_tag(:i, nil, :class => 'icon-chevron-right')).html_safe,admin_module_app_manager_auth_proc_path(ModuleApp.first(conditions: {title: "web_resource"}))), :class => active_for_app_auth('web_resource') if (is_admin? rescue nil) %> + <%= content_tag :li, link_to((t('admin.module.authorization') + content_tag(:i, nil, :class => 'icon-chevron-right')).html_safe,admin_module_app_manager_auth_proc_path(ModuleApp.first(conditions: {key: "web_resource"}))), :class => active_for_app_auth('web_resource') if (is_admin? rescue nil) %> <% end -%> <% end -%>