サンプルオブジェクトを使用してデータベースの作成を自動化しようとしているので、rakeタスクを使用します。他のウェブサイトのページのデータを使用したいと思います。その情報が読み取られて問題が発生したはずのURLリストを含むtxtファイルを作成しました。rakeタスクの外部でリクエストを行う方法がわかりません。応答を取得し、RSPECで許可されているようにセレクターを抽出する必要があります。君たちありがとう!
1 に答える
0
For custom rake tasks, you can always create your own plugin. Refer rails guide - plugins section. In the plugin, you can use get method to get the data from an external URL. Refer ActionDispatch::Integration::RequestHelpers methods for the details. You can add your own extraction logic and seed the database.
于 2012-05-06T23:52:49.963 に答える