From 571548dfbc3d1b861aa54e8b032c298e0078cbfc Mon Sep 17 00:00:00 2001 From: Benjamin Meichsner Date: Mon, 22 Mar 2010 01:58:37 +0100 Subject: [PATCH] Fixed routing bug on (ex) admin controller. --- .../{admin_controller.rb => admin/base_controller.rb} | 4 +--- app/controllers/admin/ordergroups_controller.rb | 3 +-- app/controllers/admin/users_controller.rb | 4 +--- app/controllers/admin/workgroups_controller.rb | 3 +-- app/controllers/application_controller.rb | 1 + app/controllers/login_controller.rb | 1 - app/helpers/application_helper.rb | 2 +- app/views/admin/{ => base}/index.html.haml | 0 app/views/layouts/_main_tabnav.html.erb | 4 ++-- config/routes.rb | 2 +- 10 files changed, 9 insertions(+), 15 deletions(-) rename app/controllers/{admin_controller.rb => admin/base_controller.rb} (65%) rename app/views/admin/{ => base}/index.html.haml (100%) diff --git a/app/controllers/admin_controller.rb b/app/controllers/admin/base_controller.rb similarity index 65% rename from app/controllers/admin_controller.rb rename to app/controllers/admin/base_controller.rb index e24a1bdd..e614e7ac 100644 --- a/app/controllers/admin_controller.rb +++ b/app/controllers/admin/base_controller.rb @@ -1,7 +1,5 @@ -class AdminController < ApplicationController +class Admin::BaseController < ApplicationController before_filter :authenticate_admin - filter_parameter_logging :password, :password_confirmation # do not log passwort parameters - def index @user = self.current_user diff --git a/app/controllers/admin/ordergroups_controller.rb b/app/controllers/admin/ordergroups_controller.rb index a35e32fd..fb1c0356 100644 --- a/app/controllers/admin/ordergroups_controller.rb +++ b/app/controllers/admin/ordergroups_controller.rb @@ -1,5 +1,4 @@ -class Admin::OrdergroupsController < ApplicationController - before_filter :authenticate_admin +class Admin::OrdergroupsController < Admin::BaseController def index if (params[:per_page] && params[:per_page].to_i > 0 && params[:per_page].to_i <= 100) diff --git a/app/controllers/admin/users_controller.rb b/app/controllers/admin/users_controller.rb index c1bcd98e..ce2ada44 100644 --- a/app/controllers/admin/users_controller.rb +++ b/app/controllers/admin/users_controller.rb @@ -1,6 +1,4 @@ -class Admin::UsersController < ApplicationController - before_filter :authenticate_admin - filter_parameter_logging :password, :password_confirmation # do not log passwort parameters +class Admin::UsersController < Admin::BaseController def index if (params[:per_page] && params[:per_page].to_i > 0 && params[:per_page].to_i <= 100) diff --git a/app/controllers/admin/workgroups_controller.rb b/app/controllers/admin/workgroups_controller.rb index 88462edb..e01af47a 100644 --- a/app/controllers/admin/workgroups_controller.rb +++ b/app/controllers/admin/workgroups_controller.rb @@ -1,5 +1,4 @@ -class Admin::WorkgroupsController < ApplicationController - before_filter :authenticate_admin +class Admin::WorkgroupsController < Admin::BaseController def index if (params[:per_page] && params[:per_page].to_i > 0 && params[:per_page].to_i <= 100) diff --git a/app/controllers/application_controller.rb b/app/controllers/application_controller.rb index ed15383a..06307475 100644 --- a/app/controllers/application_controller.rb +++ b/app/controllers/application_controller.rb @@ -1,5 +1,6 @@ class ApplicationController < ActionController::Base + filter_parameter_logging :password, :password_confirmation # do not log passwort parameters before_filter :select_foodcoop, :authenticate, :store_controller after_filter :remove_controller diff --git a/app/controllers/login_controller.rb b/app/controllers/login_controller.rb index 46a11267..e3388311 100644 --- a/app/controllers/login_controller.rb +++ b/app/controllers/login_controller.rb @@ -1,6 +1,5 @@ class LoginController < ApplicationController skip_before_filter :authenticate # no authentication since this is the login page - filter_parameter_logging "password" # do not log "password" parameter before_filter :validate_token, :only => [:password, :update_password] verify :method => :post, :only => [:login, :reset_password, :new], :redirect_to => { :action => :index } diff --git a/app/helpers/application_helper.rb b/app/helpers/application_helper.rb index baa8b1a3..5ea4120c 100644 --- a/app/helpers/application_helper.rb +++ b/app/helpers/application_helper.rb @@ -117,7 +117,7 @@ module ApplicationHelper end def tab_is_active?(tab) - tab[:active].detect {|c| c == controller.controller_path } + tab[:active].detect {|c| controller.controller_path.match(c) } end def icon(name, options={}) diff --git a/app/views/admin/index.html.haml b/app/views/admin/base/index.html.haml similarity index 100% rename from app/views/admin/index.html.haml rename to app/views/admin/base/index.html.haml diff --git a/app/views/layouts/_main_tabnav.html.erb b/app/views/layouts/_main_tabnav.html.erb index e0c41b55..1babc0d6 100644 --- a/app/views/layouts/_main_tabnav.html.erb +++ b/app/views/layouts/_main_tabnav.html.erb @@ -52,7 +52,7 @@ ] }, { :name => "Administration", :url => admin_root_path, - :active => ["admin", "admin/users", "admin/ordergroups", "admin/workgroups"], + :active => ["admin/"], :access_denied? => (!u.role_admin?), :subnav => [ { :name => "Benutzerinnen", :url => admin_users_path }, @@ -77,4 +77,4 @@ <% end -%> <% end -%> - \ No newline at end of file + diff --git a/config/routes.rb b/config/routes.rb index 1e8dc850..38c3ef7f 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -68,7 +68,7 @@ ActionController::Routing::Routes.draw do |map| # Administration map.namespace :admin do |admin| - admin.root :controller => "admin", :action => "index" + admin.root :controller => "base", :action => "index" admin.resources :users admin.resources :workgroups, :member => { :memberships => :get } admin.resources :ordergroups, :member => { :memberships => :get }