Forum: Ruby on Rails Problems about radio buttons

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.
B2e8b0377f92a6392087492ae329a240?d=identicon&s=25 titian1987@gmail.com (Guest)
on 2009-04-21 20:13
(Received via mailing list)
i want to set a few radio buttons and if i submit the form , i want to
change the value of the attribute from model
what should i do?

my codes are:

in view :

  <% form_for :dre, :id => @dre , :url => { :action => 'staff_demote' }
do |a|%>
  <% for active_staff in @active_staffs %>
                <tr>
  <td class="rowTitle"><a href="/admin/staff_edit/<%= active_staff.id
%>">
                <span class="researcherName"><%=h active_staff.name%></
span></a></td>
  <td><%=h active_staff.parameter %></td>

                <td><%= a.radio_button :id, active_staff.id %></td>
                </tr>
  <% end %>

in controller:

  def user
  @active_staffs = Dre.find(:all, :conditions => {:status => true})
  @inactive_staffs = Dre.find(:all, :conditions => {:status => false})
  end

   def staff_demote
  @dre = Dre.find(params[:id])
  @dre.demote
  redirect_to :action => 'user'
   end

the error messages are:

ActiveRecord::RecordNotFound in AdminController#staff_demote
Couldn't find Dre without an ID

E:/Downloads/InstantRails-2.0/ruby/lib/ruby/gems/1.8/gems/
activerecord-2.0.2/lib/active_record/base.rb:1248:in `find_from_ids'
E:/Downloads/InstantRails-2.0/ruby/lib/ruby/gems/1.8/gems/
activerecord-2.0.2/lib/active_record/base.rb:504:in `find'
app/controllers/admin_controller.rb:44:in `staff_demote'

Parameters:

{"dre"=>{"id"=>"17"},
 "commit"=>"DEMOTE USER",
 "authenticity_token"=>"5a498e80d3755a3c5caf176665d91d0a5930a4ec"}


thx for any help
This topic is locked and can not be replied to.