Is the .env file used in the Swiftype Rails example application necessary?

A little more detail for this portion of the Rails tutorial would be helpful:

Create a `.env` file with the Swiftype API Key and your engine slug:

SWIFTYPE_API_KEY=your_api_key
SWIFTYPE_ENGINE_SLUG=your_engine_slug

Where does this .env file go within the Rails app?

Also, instead of creating this .env file, can these two lines of code go in with the rest of my ENV keys in my application.yml file?

The .env file is a file defined by the Foreman gem, which lets you run Procfile applications locally as you would on Heroku. Also, the .env file sets environment variables as you would with the heroku config command. You’ll want to make sure it’s placed in the root of your Rails application.

The important thing to note is that you are able to configure your application to use your Swiftype API key and engine key. Putting these in environment variables is just one way to do it. As long as it works, use whatever method you like.