Ruby on Rails | Screencasts | Download | Documentation | Weblog | Community | Source

Ticket #7543 (new defect)

Opened 1 year ago

Last modified 1 year ago

[PATCH] Lets ActiveResources be created w/ a nil argument

Reported by: sneakin Assigned to: core
Priority: high Milestone: 2.x
Component: ActiveResource Version: edge
Severity: major Keywords: activeresource load nil create new instantiate no attributes params
Cc:

Description

ActiveResource doesn't allow for what could be called the typical usage of ActiveRecord in controllers:

@record = Record.new(params[:record])

If that is done with an ActiveResource an ArgumentError gets raised. This patch adds a check to ActiveResource::Base#load to see if the supplied attributes Hash is nil which causes a bulk of the code to be skipped.

Attachments

load_nils.diff (1.6 kB) - added by sneakin on 02/12/07 21:33:49.
Lets ActiveResource "load" nils

Change History

02/12/07 21:33:49 changed by sneakin

  • attachment load_nils.diff added.

Lets ActiveResource "load" nils

02/12/07 21:35:39 changed by sneakin

Guess I should have noted above that params[:record] may or may not have a value. As fellow Rails users, I assume you've done the example before.