titian1987-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org
2009-Apr-21 15:52 UTC
Problems about radio buttons
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