On Nov 17, 3:39 pm, codefusurfer <[email protected]> wrote:

>
>   def update
>      User.update(params[:user].keys, params[:user].values]
>   end

This would work if params[:user] was of the form {1 => {'internal' =>
true}, 2 => {'internal' => false}}
However that's not what you've got.

There are several problems:
- what you get out of the params hash is always a string ie you'll be
receiving the string 'true' rather than the boolean value true. If
your values are '1' and  '0' then Active Record (if  my memory is
correct)  will do the appropriate coercing to true / false
- you're using radio buttons in a really odd way - seems to that check
boxes would be more appropriate
- unchecked checkboxes etc don't submit a value at all, you probably
want to either reuse the rails check_box (not the same as
check_box_tag) helper or use the same trick as it does (include a
hidden field with the same name and the appropriate parameter value).

Lastly there are few things as uninformative as saying 'it doesn't
work' - tell us what goes wrong.

Fred

>
>  Of course this is not working otherwise I wouldn't asking for help.
> Can anyone tell me what is the best way to achieve my goal of updating
> the User internal and admin boolean entries via a html form. Thanks
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups "Ruby 
on Rails: Talk" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to 
[email protected]
For more options, visit this group at 
http://groups.google.com/group/rubyonrails-talk?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to