Hi,
I am trying to populate a legacy table with a primary key of
''id'', but
the id is not auto-incremented (the id is currently populated with the
results from another table that has an auto-incremented id).
I''m POSTing xml to a controller created by the scaffold_resource
generator
e.g.:
echo ''
<user>
<id>2</id>
<name>Tom</name>
</user>'' | curl -X POST -H ''Content-type:
text/xml'' -d @-
http://localhost:3000/users
However, the id specified in the xml is not saved.
The development log shows the following parameters being received:
Parameters: {"user"=>{"name"=>"Dick",
"id"=>"2"}, "action"=>"create",
"controller"=>"users"}
However, in users_controller.create, I am having to explicitly set the
id myself
@user = User.new(params[:user])
@user.id = params[:user][:id]
Is there a better way to do this? A setting perhaps regarding a non-
autoincremented primary key?
Thanks,
Shawn
--~--~---------~--~----~------------~-------~--~----~
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
-~----------~----~----~----~------~----~------~--~---