The problem is that you've got form_for [:admin, :user] instead of  
form_for [:admin, @user] and then you're expecting (somehow)  
f.radio_button to know which user to use to retrieve the seed value.   
Rails is using the last element of that array and calling  
the .approval method on it (hence the error about the user:Symbol  
(ie. :user ) not having that method defined.

You're more likely to want to put the form within the @users iteration  
block, so that you have a separate form for each user.  You can then do:

   <% for user in @users %>
     <% form_for [:admin, user] ...etc. do %>
       <%= f.radio_button :approval ...etc. %>


If not, if you want it all in one form, then you won't be able to use  
the form_for block helpers, rather you'll need to use radio_button_tag  
and setup the values and names manually.

Regards,
Jason

On Sep 22, 2009, at 11:30 AM, liquid_rails wrote:

>
> I'm trying to generate a list of users with two radio buttons next to
> each user where I can either approve or reject a user, all in the same
> form.
> The following code, illustrates what I am trying to do and the error I
> am getting.
> Does anybody know how to do this?  Thanks in advance!  - Cheri
>
>  create_table "users", :force => true do |t|
>    t.string   "name"
>    t.integer  "approval", :default => 0  # 0=needs approval,
> 1=approved, 2=not approved
>  end
> -------------------
>
> <% form_for [:admin, :user], :url => {:action => "user_approval" }  do
> |f| %>
>  <% for user in @users %>
>    <tr>
>      <td><%= user.id %></td>
>      <td><%= user.name %></td>
>      <td><%= user.approval %></td>  #current state of the user's
> approval status
>      <td><%= f.radio_button :approval,'1' %>"Approve" </td>
>      <td><%= f.radio_button :approval,'2'  %>"Reject" </td>
>    </tr>
>  <% end %>
> <p> <%= f.submit "Submit" %> </p>
> <% end %>
>
> ---------
> Error:
> undefined method `approval' for :user:Symbol
> >


--~--~---------~--~----~------------~-------~--~----~
SD Ruby mailing list
[email protected]
http://groups.google.com/group/sdruby
-~----------~----~----~----~------~----~------~--~---

Reply via email to