Skip to content
This repository has been archived by the owner on Nov 17, 2017. It is now read-only.

Commit

Permalink
Added bypass for attr_protected / attr_accessible. Enables admin form…
Browse files Browse the repository at this point in the history
…s to work for all fields on all models
  • Loading branch information
jcnetdev committed Sep 17, 2008
1 parent a6530bc commit b38b9f7
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions lib/auto_admin_controller.rb
Expand Up @@ -152,7 +152,7 @@ def save
end

# Save attributes on the primary object
@object.attributes = params[params[:model]]
@object.send :attributes=, params[params[:model]], false
unless @object.save
flash[:warning] = "Failed to update the #{human_model.downcase} \"#{@object.to_label}\". "
render :action => 'edit' and return
Expand Down Expand Up @@ -194,7 +194,10 @@ def save
end

o = child_id ? child_class.find( child_id ) : children.build
unless o.update_attributes child_info

# update attributes, ignoring protected
o.send :attributes=, child_info, false
unless o.save
set_name = 'Child list'
set_name = set.name if set.respond_to?(:name) && !set.name.blank?
flash[:warning] = "Failed to #{o.new_record? ? 'add' : 'change'} the #{o.class.name.titleize.downcase} \"#{o.to_label}\" (#{set_name})"
Expand Down

0 comments on commit b38b9f7

Please sign in to comment.