Forum: Ruby on Rails disable protected attributes for create or save

Announcement (2017-05-07): www.ruby-forum.com is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see rubyonrails.org/community and ruby-lang.org/en/community for other Rails- und Ruby-related community platforms.
3518ff338e5eee9b32eb1815daabc602?d=identicon&s=25 Marcelo Barbudas (Guest)
on 2008-10-29 15:54
(Received via mailing list)
Hi,

Is there a way to temporarily disable attr_protected for create and
save method calls?

Something like save_without_protected...

--
M.
81b61875e41eaa58887543635d556fca?d=identicon&s=25 Frederick Cheung (Guest)
on 2008-10-29 16:01
(Received via mailing list)
On 29 Oct 2008, at 14:53, Marcelo Barbudas wrote:

>
> Hi,
>
> Is there a way to temporarily disable attr_protected for create and
> save method calls?
>
> Something like save_without_protected...
>
The bit to realise is that it's not save that's doing the protecting -
it's the assigning to attributes.

Something like

foo  = SomeObject.new
foo.send :attributes=, some_attributes, false
foo.save

will create a new instance of foo, ignoring protected attributes.

Fred
This topic is locked and can not be replied to.