既存のアプリケーションと統合する Rails アプリを開発しています。Mule と安静なインターフェースを使用して、2 つのアプリケーション間でデータを移動します。
Priority や Types など、古いアプリから新しいアプリへのコード テーブルがいくつかあります。両方のアプリケーションに同じ ID 番号を使用できれば、それらの ID を外部キーに使用するデータ レコードを簡単に移動できます。
Railsの安らかなインターフェースを介して更新されるフィールドの1つにIDを許可する方法はありますか?
これが機能することを望みます:
http://localhost:5000/types?type[id]=315&type[typecode]=test
これは 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
現在、その URL を投稿すると、typecode=test で新しいタイプ レコードが作成されますが、ID は、URL で指定した ID ではなく、次に使用可能な ID です。
助けてくれてありがとう!