This sounds exactly like the problem I was just having
with update_attributes.
Do you have any attr_accessibles in the Abuser class?
It seems that if you have NO attr_accessible
declarations, then everything is fine. As soon as you
add one, then none of your other properties are
accessible anymore unless you declare each and every
one of them with attr_accessible.
In my case, after I added the remainder of the
properties to my Product class with attr_accessible,
my problems went away.
It seems that inside attributes=(), a call is made to
remove_attributes_protected_from_mass_assignment which
will discard any of your params that are not in the
list returned from self.class.accessible_attributes
(which is the list of attributes declared with
attr_accessible). If no attributes are declared with
attr_accessible, the call to
self.class.accessible_attributes returns nil and the
params are left intact.
Hope this helps.
--- Alex Reuter <reuter-PkbjNfxxIARBDgjK7y7TUQ@public.gmane.org> wrote:
> Hi,
> I have a database table users and using STI have a
> subclass of User called
> Abuser
>
> This code
> new_abuser = Abuser.new(@params["abuser"])
> results in new_admin having null values for all its
> properties.
>
> the @params are not complete, they are missing both
> name and password, but have
> Parameters: {"abuser"=>
> {"first_name"=>"l",
"last_name"=>"l", "email"=>"l"},
> "action"=>"abuser_details"
> , "controller"=>"abuser_wizard"}
>
> After the Abuser.new call, the new_abuser variable
> doesn''t even have a
> first_name.
>
> I''m not sure why. Anyone encounter anything like
> this?
> Its not really a big deal, I just wrote custom
> debriefing code, but I''m no
> ruby expert and its not very elegant.
>
> TIA
> -Alex
>
> p.s. User is basically just like the User class in
> Agile Web Dev w/Rails and
> the Abuser class adds 2 relationships which the user
> doesn''t have.
>
>
>
> _______________________________________________
> Rails mailing list
> Rails-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org
> http://lists.rubyonrails.org/mailman/listinfo/rails
>
__________________________________
Yahoo! Mail - PC Magazine Editors'' Choice 2005
http://mail.yahoo.com