Hi,
I used scaffold to generate the basic structure for the application.
The application has two table like this:
| ID | UserName | ServerID |
| 1 | AAA | 1 |
| 2 | BBB | 1 |
| ServerID | Name | Application |
| 1 | A | CCC |
In _form.rhtml, I have a select drop down box that would display the
server name instead of serverID to let user to choose from.
<%= collection_select :user, :serverid, Server.find(:all), :id,
:application %>
There is no problem when I tried to create a new user, but when I tried
to update user BBB, it would complain "Can''t find Server with
ID=2".
Here''s my new.rhtml
<%= start_form_tag :action => ''create'' %>
<%= render :partial => ''form'' %>
<%= submit_tag "create" %>
<%= end_form_tag %>
Here''s my edit.rhtml
<%= start_form_tag :action => ''update'', :id =>
@deploy %>
<%= render :partial => ''form'' %>
<%= submit_tag ''update'' %>
<%= end_form_tag %>
Here''s my users_controller.rb
def edit
@user = User.find(params[:id])
end
def update
@user = User.find(params[:id])
if @user.update_attributes(params[:user])
flash[:notice] = ''User was successfully updated.''
redirect_to :action => ''show'', :id => @user
else
render :action => ''edit''
end
end
It does not make sense that it can create fine, but failed to update
using the same _form. Does anyone have any idea or way to troubleshoot
this problem?
--
Posted via http://www.ruby-forum.com/.
--~--~---------~--~----~------------~-------~--~----~
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
rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org
To unsubscribe from this group, send email to
rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org
For more options, visit this group at
http://groups.google.com/group/rubyonrails-talk?hl=en
-~----------~----~----~----~------~----~------~--~---