We are developing a Rails app that integrates with an existing application. We are using Mule and restful interfaces to move data between the 2 applications.
We have a few code tables like Priority and Types that come from the old app to the new app. If we can use the same ID numbers for both applications, it will be easier to move data records that use those IDs for foreign-keys.
Is there a way to allow the ID to be one of the fields that gets updated via the Rails restful interface?
I would like this to work:
http://localhost:5000/types?type[id]=315&type[typecode]=test
This is the type controller for POST:
# POST /types
# POST /types.json
def create
@type = Type.new(params[:type])
respond_to do |format|
if @type.save
format.html { redirect_to @type, notice: 'Type was successfully created.' }
format.json { render json: @type, status: :created, location: @type }
format.xml { render xml: @type, status: :created, location: @type }
else
format.html { render action: "new" }
format.json { render json: @type.errors, status: :unprocessable_entity }
format.xml { render xml: @type.errors, status: :unprocessable_entity }
end
end
end
Right now, if I post that URL, it creates a new type record with typecode=test, but the id is the next available id instead of the one I gave it in the URL.
Thanks for the help!