Permalink
Browse files

Wrong detection of the resources was making that namespaced models we…

…re not updated.
  • Loading branch information...
1 parent 94e18ee commit cbaf25fa26cdb9beb5a1cfe87f54ebcee0e97a36 Francesc Esplugas committed Feb 21, 2010
Showing with 6 additions and 6 deletions.
  1. +5 −5 app/controllers/admin/master_controller.rb
  2. +1 −1 lib/typus/authentication.rb
View
10 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}}.",
View
2 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

0 comments on commit cbaf25f

Please sign in to comment.