Skip to content

Commit

Permalink
Wrong detection of the resources was making that namespaced models we…
Browse files Browse the repository at this point in the history
…re not updated.
  • Loading branch information
Francesc Esplugas committed Feb 21, 2010
1 parent 94e18ee commit cbaf25f
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 6 deletions.
10 changes: 5 additions & 5 deletions app/controllers/admin/master_controller.rb
Expand Up @@ -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 }
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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}}.",
Expand Down
2 changes: 1 addition & 1 deletion lib/typus/authentication.rb
Expand Up @@ -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

Expand Down

0 comments on commit cbaf25f

Please sign in to comment.