From cbaf25fa26cdb9beb5a1cfe87f54ebcee0e97a36 Mon Sep 17 00:00:00 2001 From: Francesc Esplugas Date: Sun, 21 Feb 2010 21:31:51 +0100 Subject: [PATCH] Wrong detection of the resources was making that namespaced models were not updated. --- app/controllers/admin/master_controller.rb | 10 +++++----- lib/typus/authentication.rb | 2 +- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/app/controllers/admin/master_controller.rb b/app/controllers/admin/master_controller.rb index d6caa45f3..996238e10 100644 --- a/app/controllers/admin/master_controller.rb +++ b/app/controllers/admin/master_controller.rb @@ -86,7 +86,7 @@ def new # def create - @item = @resource[:class].new(params[@resource[:symbol]]) + @item = @resource[:class].new(params[@object_name]) if @resource[:class].typus_user_id? @item.attributes = { Typus.user_fk => @current_user.id } @@ -140,7 +140,7 @@ def show def update - if @item.update_attributes(params[@resource[:symbol]]) + if @item.update_attributes(params[@object_name]) if @resource[:class].typus_user_id? && !@current_user.is_root? @item.update_attributes Typus.user_fk => @current_user.id @@ -271,8 +271,8 @@ def current_user def set_resource @resource = { :self => params[:controller].extract_resource, :human_name => params[:controller].extract_human_name, - :class => params[:controller].extract_class, - :symbol => params[:controller].extract_resource.singularize.to_sym } + :class => params[:controller].extract_class } + @object_name = ActionController::RecordIdentifier.singular_class_name(@resource[:class]) rescue Exception => error error_handler(error) end @@ -389,7 +389,7 @@ def create_with_back_to message = _("{{model}} successfully created.", :model => @resource[:human_name]) path = "#{params[:back_to]}?#{params[:selected]}=#{@item.id}" when :polymorphic - resource.send(@item.class.name.tableize).create(params[@resource[:symbol]]) + resource.send(@item.class.name.tableize).create(params[@object_name]) end flash[:success] = message || _("{{model_a}} successfully assigned to {{model_b}}.", diff --git a/lib/typus/authentication.rb b/lib/typus/authentication.rb index 56934f345..62a42bc7f 100644 --- a/lib/typus/authentication.rb +++ b/lib/typus/authentication.rb @@ -60,7 +60,7 @@ def check_if_user_can_perform_action_on_user when 'update' # current_user cannot change her role. - if current_user && !(@item.role == params[@resource[:symbol]][:role]) + if current_user && !(@item.role == params[@object_name][:role]) _("You can't change your role.") end