Qman
Qman

Reputation: 43

How to put Rails environment variable in apple-app-site-association file for universal links?

So currently I have inside the public folder a file called "apple-app-site-association" with the content:

{"applinks":{"apps":[],"details":[{"appID":"{#Rails.configuration.appID}","paths":"*"}]}}

Obviously the {#Rails.configuration.appID} is not being generated dynamically and is being output literally, but I would like it to be reading from the config file, where appID is defined. How can I go about this??

Upvotes: 4

Views: 1702

Answers (1)

Josh Brody
Josh Brody

Reputation: 5363

The most straightforward way would be to just add a route.

get '/apple-app-site-association' => 'pages#apple_app_site_association'

def apple_app_site_association
  render :json => {"applinks":{"apps":[],"details":[{"appID": Rails.configuration.appID,"paths":"*"}]}}
end

You may need to do more than that, but that should at least get you moving in the right direction.

Update 2020: Typo in route path fixed

Upvotes: 6

Related Questions